云网牛站
所在位置:首页 > Linux安全 > 在Redhat(RHEL)和CentOS系统上检查或列出已经安装的安全更新

在Redhat(RHEL)和CentOS系统上检查或列出已经安装的安全更新

2019-05-30 16:09:56作者:高风科稿源:云网牛站

如果你已经在Redhat(RHEL)和CentOS操作系统上安装了安全更新,你如何检查或列出已经安装的安全更新,本文向你介绍两种方法。此外,我添加了一个小的shell脚本,它为你提供有关已安装的安全包计数的摘要。

在Redhat(RHEL)和CentOS系统上检查或列出已经安装的安全更新

 

方法一

运行以下命令以获取系统上已安装的安全更新的列表:

# yum updateinfo list security installed

Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,

 : subscription-manager, verify, versionlock

RHSA-2015:2315 Moderate/Sec.  ModemManager-glib-1.1.0-8.git20130913.el7.x86_64

RHSA-2015:2315 Moderate/Sec.  NetworkManager-1:1.0.6-27.el7.x86_64

RHSA-2016:2581 Low/Sec.       NetworkManager-1:1.4.0-12.el7.x86_64

RHSA-2017:2299 Moderate/Sec.  NetworkManager-1:1.8.0-9.el7.x86_64

RHSA-2015:2315 Moderate/Sec.  NetworkManager-adsl-1:1.0.6-27.el7.x86_64

RHSA-2016:2581 Low/Sec.       NetworkManager-adsl-1:1.4.0-12.el7.x86_64

RHSA-2017:2299 Moderate/Sec.  NetworkManager-adsl-1:1.8.0-9.el7.x86_64

RHSA-2015:2315 Moderate/Sec.  NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64

要计算已安装的安全包的数量,请运行以下命令:

# yum updateinfo list security installed | wc -l

1046

仅打印安装包列表:

# yum updateinfo list security all | grep -w "i"

i RHSA-2015:2315 Moderate/Sec.  ModemManager-glib-1.1.0-8.git20130913.el7.x86_64

i RHSA-2015:2315 Moderate/Sec.  NetworkManager-1:1.0.6-27.el7.x86_64

i RHSA-2016:2581 Low/Sec.       NetworkManager-1:1.4.0-12.el7.x86_64

i RHSA-2017:2299 Moderate/Sec.  NetworkManager-1:1.8.0-9.el7.x86_64

i RHSA-2015:2315 Moderate/Sec.  NetworkManager-adsl-1:1.0.6-27.el7.x86_64

i RHSA-2016:2581 Low/Sec.       NetworkManager-adsl-1:1.4.0-12.el7.x86_64

i RHSA-2017:2299 Moderate/Sec.  NetworkManager-adsl-1:1.8.0-9.el7.x86_64

i RHSA-2015:2315 Moderate/Sec.  NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64

i RHSA-2016:2581 Low/Sec.       NetworkManager-bluetooth-1:1.4.0-12.el7.x86_64

i RHSA-2017:2299 Moderate/Sec.  NetworkManager-bluetooth-1:1.8.0-9.el7.x86_64

i RHSA-2015:2315 Moderate/Sec.  NetworkManager-config-server-1:1.0.6-27.el7.x86_64

i RHSA-2016:2581 Low/Sec.       NetworkManager-config-server-1:1.4.0-12.el7.x86_64

i RHSA-2017:2299 Moderate/Sec.  NetworkManager-config-server-1:1.8.0-9.el7.noarch

要计算已安装的安全包的数量,请运行以下命令:

# yum updateinfo list security all | grep -w "i" | wc -l

1043

或者,可以检查针对给定包修复的漏洞列表。

在此示例中,我们将检查“openssh”包中已修复的漏洞列表:

# rpm -q --changelog openssh | grep -i CVE

- Fix for CVE-2017-15906

- CVE-2015-8325: privilege escalation via user's PAM environment and UseLogin=yes

- CVE-2016-1908: possible fallback from untrusted to trusted X11 forwarding

- CVE-2016-3115: missing sanitisation of input for X11 forwarding

- prevents CVE-2016-0777 and CVE-2016-0778

- Security fixes released with openssh-6.9 (CVE-2015-5352)

- only query each keyboard-interactive device once (CVE-2015-5600)

- add new option GSSAPIEnablek5users and disable using ~/.k5users by default CVE-2014-9278

- prevent a server from skipping SSHFP lookup - CVE-2014-2653

- change default value of MaxStartups - CVE-2010-5107

- CVE-2010-4755

- merged cve-2007_3102 to audit patch

- fixed audit log injection problem (CVE-2007-3102)

- CVE-2006-5794 - properly detect failed key verify in monitor

- CVE-2006-4924 - prevent DoS on deattack detector

- CVE-2006-5051 - don't call cleanups from signal handler

- use fork+exec instead of system in scp - CVE-2006-0225

参考:信息安全中常用术语介绍

同样,你可以通过运行以下命令来检查相应程序包中是否修复了给定的漏洞:

# rpm -q --changelog openssh | grep -i CVE-2016-3115

- CVE-2016-3115: missing sanitisation of input for X11 forwarding

 

方法二

本方法使用Shell脚本计算已安装的安全包。

我添加了一个小的shell脚本,它可以帮助你计算已安装的安全包列表:

# vi /opt/scripts/security-check.sh

#!/bin/bash

echo "+-------------------------+"

echo "|Security Advisories Count|"

echo "+-------------------------+"

for i in Important Moderate Low

do

sec=$(yum updateinfo list security installed | grep $i | wc -l)

echo "$i: $sec"

done | column -t

echo "+-------------------------+"

为security-check.sh文件设置可执行权限:

$ chmod +x security-check.sh

参考:在Linux系统中运行.sh文件的两种方法

最后运行脚本来实现这一目标:

# sh /opt/scripts/security-check.sh

|Security Advisories Count|

Important: 480

Moderate: 410

Low: 111

上面得出的结果是:重要为480、中等为410、低为111。

 

相关主题

在Ubuntu 18.04服务器上设置自动安全更新(无人值守升级)

精选文章
热门文章