在RHEL和CentOS上检查或列出已安装的安全更新的两种方法

系统 Linux
在本文中,我们将向你展示如何检查已安装的安全更新。我会介绍两种方法,你可以选择最适合你的。

[[267757]]

我们过去曾写过两篇关于这个主题的文章,每篇文章都是根据不同的要求发表的。如果你想在开始之前浏览这些文章。请通过以下链接:

 

这些文章与其他文章相互关联,因此,在深入研究之前,最好先阅读这些文章。

在本文中,我们将向你展示如何检查已安装的安全更新。我会介绍两种方法,你可以选择最适合你的。

此外,我还添加了一个小的 shell 脚本,它为你提供已安装的安全包计数。

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

  1. # yum updateinfo list security installed
  2.  
  3. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  4. : subscription-manager, verify, versionlock
  5. RHSA-2015:2315 Moderate/Sec. ModemManager-glib-1.1.0-8.git20130913.el7.x86_64
  6. RHSA-2015:2315 Moderate/Sec. NetworkManager-1:1.0.6-27.el7.x86_64
  7. RHSA-2016:2581 Low/Sec. NetworkManager-1:1.4.0-12.el7.x86_64
  8. RHSA-2017:2299 Moderate/Sec. NetworkManager-1:1.8.0-9.el7.x86_64
  9. RHSA-2015:2315 Moderate/Sec. NetworkManager-adsl-1:1.0.6-27.el7.x86_64
  10. RHSA-2016:2581 Low/Sec. NetworkManager-adsl-1:1.4.0-12.el7.x86_64
  11. RHSA-2017:2299 Moderate/Sec. NetworkManager-adsl-1:1.8.0-9.el7.x86_64
  12. RHSA-2015:2315 Moderate/Sec. NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64

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

  1. # yum updateinfo list security installed | wc -l
  2. 1046

仅打印安装包列表:

  1. # yum updateinfo list security all | grep -w "i"
  2.  
  3. i RHSA-2015:2315 Moderate/Sec. ModemManager-glib-1.1.0-8.git20130913.el7.x86_64
  4. i RHSA-2015:2315 Moderate/Sec. NetworkManager-1:1.0.6-27.el7.x86_64
  5. i RHSA-2016:2581 Low/Sec. NetworkManager-1:1.4.0-12.el7.x86_64
  6. i RHSA-2017:2299 Moderate/Sec. NetworkManager-1:1.8.0-9.el7.x86_64
  7. i RHSA-2015:2315 Moderate/Sec. NetworkManager-adsl-1:1.0.6-27.el7.x86_64
  8. i RHSA-2016:2581 Low/Sec. NetworkManager-adsl-1:1.4.0-12.el7.x86_64
  9. i RHSA-2017:2299 Moderate/Sec. NetworkManager-adsl-1:1.8.0-9.el7.x86_64
  10. i RHSA-2015:2315 Moderate/Sec. NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64
  11. i RHSA-2016:2581 Low/Sec. NetworkManager-bluetooth-1:1.4.0-12.el7.x86_64
  12. i RHSA-2017:2299 Moderate/Sec. NetworkManager-bluetooth-1:1.8.0-9.el7.x86_64
  13. i RHSA-2015:2315 Moderate/Sec. NetworkManager-config-server-1:1.0.6-27.el7.x86_64
  14. i RHSA-2016:2581 Low/Sec. NetworkManager-config-server-1:1.4.0-12.el7.x86_64
  15. i RHSA-2017:2299 Moderate/Sec. NetworkManager-config-server-1:1.8.0-9.el7.noarch

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

  1. # yum updateinfo list security all | grep -w "i" | wc -l
  2. 1043

或者,你可以检查指定包修复的漏洞列表。

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

  1. # rpm -q --changelog openssh | grep -i CVE
  2.  
  3. - Fix for CVE-2017-15906 (#1517226)
  4. - CVE-2015-8325: privilege escalation via user's PAM environment and UseLogin=yes (#1329191)
  5. - CVE-2016-1908: possible fallback from untrusted to trusted X11 forwarding (#1298741)
  6. - CVE-2016-3115: missing sanitisation of input for X11 forwarding (#1317819)
  7. - prevents CVE-2016-0777 and CVE-2016-0778
  8. - Security fixes released with openssh-6.9 (CVE-2015-5352) (#1247864)
  9. - only query each keyboard-interactive device once (CVE-2015-5600) (#1245971)
  10. - add new option GSSAPIEnablek5users and disable using ~/.k5users by default CVE-2014-9278
  11. - prevent a server from skipping SSHFP lookup - CVE-2014-2653 (#1081338)
  12. - change default value of MaxStartups - CVE-2010-5107 (#908707)
  13. - CVE-2010-4755
  14. - merged cve-2007_3102 to audit patch
  15. - fixed audit log injection problem (CVE-2007-3102)
  16. - CVE-2006-5794 - properly detect failed key verify in monitor (#214641)
  17. - CVE-2006-4924 - prevent DoS on deattack detector (#207957)
  18. - CVE-2006-5051 - don't call cleanups from signal handler (#208459)
  19. - use fork+exec instead of system in scp - CVE-2006-0225 (#168167)

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

  1. # rpm -q --changelog openssh | grep -i CVE-2016-3115
  2.  
  3. - CVE-2016-3115: missing sanitisation of input for X11 forwarding (#1317819)

如何使用 Shell 脚本计算安装的安全包?

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

  1. # vi /opt/scripts/security-check.sh
  2.  
  3. #!/bin/bash
  4. echo "+-------------------------+"
  5. echo "|Security Advisories Count|"
  6. echo "+-------------------------+"
  7. for i in Important Moderate Low
  8. do
  9. sec=$(yum updateinfo list security installed | grep $i | wc -l)
  10. echo "$i: $sec"
  11. done | column -t
  12. echo "+-------------------------+"

security-check.sh 文件执行权限。

  1. $ chmod +x security-check.sh

最后执行脚本统计。

  1. # sh /opt/scripts/security-check.sh
  2.  
  3. +-------------------------+
  4. |Security Advisories Count|
  5. +-------------------------+
  6. Important: 480
  7. Moderate: 410
  8. Low: 111
  9. +-------------------------+

 

责任编辑:庞桂玉 来源: Linux中国
相关推荐

2019-06-05 10:20:09

安全更新命令Linux

2016-12-07 18:12:05

CentOSRHEL安全补丁

2020-09-15 09:48:41

PHP

2010-08-04 17:41:52

挂载NFS

2010-07-26 15:42:34

Perl模块

2011-09-19 10:25:59

VimUbuntu

2019-02-25 09:55:32

UbuntuDebian软件包

2011-03-30 17:04:24

MySQL添加用户

2010-11-24 14:36:25

修复mysql表

2009-09-25 14:04:09

Hibernate eHibernate h

2010-04-13 09:50:44

Oracle跟踪

2021-09-02 00:13:41

Windows 11Windows微软

2009-08-03 17:53:11

XML数据

2010-02-06 14:35:36

ibmdwRUP迭代

2009-08-05 13:34:18

C#日期相减

2010-09-09 19:53:50

2010-09-07 11:18:10

2009-06-18 11:09:42

2010-11-12 11:44:37

SQL Server删

2020-09-16 18:27:36

Linux方法IP地址
点赞
收藏

51CTO技术栈公众号