如何在CentOS或RHEL系统上检查可用的安全更新?

系统 Linux
在这篇文章中,我们不但会提供所需的信息。而且,我们会介绍一些额外的命令,可以帮你获取指定安全更新的详实信息。

 [[267218]]

当你更新系统时,根据你所在公司的安全策略,有时候可能只需要打上与安全相关的补丁。大多数情况下,这应该是出于程序兼容性方面的考量。那该怎样实践呢?有没有办法让 yum 只安装安全补丁呢?

答案是肯定的,可以用 yum 包管理器轻松实现。

在这篇文章中,我们不但会提供所需的信息。而且,我们会介绍一些额外的命令,可以帮你获取指定安全更新的详实信息。

希望这样可以启发你去了解并修复你列表上的那些漏洞。一旦有安全漏洞被公布,就必须更新受影响的软件,这样可以降低系统中的安全风险。

对于 RHEL 或 CentOS 6 系统,运行下面的 Yum 命令 来安装 yum 安全插件。

  1. # yum -y install yum-plugin-security

在 RHEL 7&8 或是 CentOS 7&8 上面,这个插件已经是 yum 的一部分了,不用单独安装。

要列出全部可用的补丁(包括安全、Bug 修复以及产品改进),但不安装它们:

  1. # yum updateinfo list available
  2. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  3. : subscription-manager, verify, versionlock
  4. RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
  5. RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
  6. RHBA-2015:0626 bugfix 389-ds-base-1.3.3.1-15.el7_1.x86_64
  7. RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64
  8. RHBA-2015:1554 bugfix 389-ds-base-1.3.3.1-20.el7_1.x86_64
  9. RHBA-2015:1960 bugfix 389-ds-base-1.3.3.1-23.el7_1.x86_64
  10. RHBA-2015:2351 bugfix 389-ds-base-1.3.4.0-19.el7.x86_64
  11. RHBA-2015:2572 bugfix 389-ds-base-1.3.4.0-21.el7_2.x86_64
  12. RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64
  13. RHBA-2016:0550 bugfix 389-ds-base-1.3.4.0-29.el7_2.x86_64
  14. RHBA-2016:1048 bugfix 389-ds-base-1.3.4.0-30.el7_2.x86_64
  15. RHBA-2016:1298 bugfix 389-ds-base-1.3.4.0-32.el7_2.x86_64

要统计补丁的大约数量,运行下面的命令:

  1. # yum updateinfo list available | wc -l
  2. 11269

想列出全部可用的安全补丁但不安装,以下命令用来展示你系统里已安装和待安装的推荐补丁:

  1. # yum updateinfo list security all
  2. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  3. : subscription-manager, verify, versionlock
  4. RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
  5. RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
  6. RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64
  7. RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64
  8. RHSA-2016:2594 Moderate/Sec. 389-ds-base-1.3.5.10-11.el7.x86_64
  9. RHSA-2017:0920 Important/Sec. 389-ds-base-1.3.5.10-20.el7_3.x86_64
  10. RHSA-2017:2569 Moderate/Sec. 389-ds-base-1.3.6.1-19.el7_4.x86_64
  11. RHSA-2018:0163 Important/Sec. 389-ds-base-1.3.6.1-26.el7_4.x86_64
  12. RHSA-2018:0414 Important/Sec. 389-ds-base-1.3.6.1-28.el7_4.x86_64
  13. RHSA-2018:1380 Important/Sec. 389-ds-base-1.3.7.5-21.el7_5.x86_64
  14. RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64
  15. RHSA-2018:3127 Moderate/Sec. 389-ds-base-1.3.8.4-15.el7.x86_64
  16. RHSA-2014:1031 Important/Sec. 389-ds-base-libs-1.3.1.6-26.el7_0.x86_64

要显示所有待安装的安全补丁:

  1. # yum updateinfo list security all | grep -v "i"
  2.  
  3. RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64
  4. RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64
  5. RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64
  6. RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64
  7. RHSA-2016:2594 Moderate/Sec. 389-ds-base-1.3.5.10-11.el7.x86_64
  8. RHSA-2017:0920 Important/Sec. 389-ds-base-1.3.5.10-20.el7_3.x86_64
  9. RHSA-2017:2569 Moderate/Sec. 389-ds-base-1.3.6.1-19.el7_4.x86_64
  10. RHSA-2018:0163 Important/Sec. 389-ds-base-1.3.6.1-26.el7_4.x86_64
  11. RHSA-2018:0414 Important/Sec. 389-ds-base-1.3.6.1-28.el7_4.x86_64
  12. RHSA-2018:1380 Important/Sec. 389-ds-base-1.3.7.5-21.el7_5.x86_64
  13. RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64

要统计全部安全补丁的大致数量,运行下面的命令:

  1. # yum updateinfo list security all | wc -l
  2. 3522

下面根据已装软件列出可更新的安全补丁。这包括 bugzilla(bug 修复)、CVE(知名漏洞数据库)、安全更新等:

  1. # yum updateinfo list security
  2.  
  3. 或者
  4.  
  5. # yum updateinfo list sec
  6.  
  7. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  8. : subscription-manager, verify, versionlock
  9.  
  10. RHSA-2018:3665 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64
  11. RHSA-2018:3665 Important/Sec. NetworkManager-adsl-1:1.12.0-8.el7_6.x86_64
  12. RHSA-2018:3665 Important/Sec. NetworkManager-bluetooth-1:1.12.0-8.el7_6.x86_64
  13. RHSA-2018:3665 Important/Sec. NetworkManager-config-server-1:1.12.0-8.el7_6.noarch
  14. RHSA-2018:3665 Important/Sec. NetworkManager-glib-1:1.12.0-8.el7_6.x86_64
  15. RHSA-2018:3665 Important/Sec. NetworkManager-libnm-1:1.12.0-8.el7_6.x86_64
  16. RHSA-2018:3665 Important/Sec. NetworkManager-ppp-1:1.12.0-8.el7_6.x86_64
  17. RHSA-2018:3665 Important/Sec. NetworkManager-team-1:1.12.0-8.el7_6.x86_64
  18. RHSA-2018:3665 Important/Sec. NetworkManager-tui-1:1.12.0-8.el7_6.x86_64
  19. RHSA-2018:3665 Important/Sec. NetworkManager-wifi-1:1.12.0-8.el7_6.x86_64
  20. RHSA-2018:3665 Important/Sec. NetworkManager-wwan-1:1.12.0-8.el7_6.x86_64

显示所有与安全相关的更新,并且返回一个结果来告诉你是否有可用的补丁:

  1. # yum --security check-update
  2. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
  3. rhel-7-server-rpms | 2.0 kB 00:00:00
  4. --> policycoreutils-devel-2.2.5-20.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo)
  5. --> smc-raghumalayalam-fonts-6.0-7.el7.noarch from rhel-7-server-rpms excluded (updateinfo)
  6. --> amanda-server-3.3.3-17.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo)
  7. --> 389-ds-base-libs-1.3.4.0-26.el7_2.x86_64 from rhel-7-server-rpms excluded (updateinfo)
  8. --> 1:cups-devel-1.6.3-26.el7.i686 from rhel-7-server-rpms excluded (updateinfo)
  9. --> openwsman-client-2.6.3-3.git4391e5c.el7.i686 from rhel-7-server-rpms excluded (updateinfo)
  10. --> 1:emacs-24.3-18.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo)
  11. --> augeas-libs-1.4.0-2.el7_4.2.i686 from rhel-7-server-rpms excluded (updateinfo)
  12. --> samba-winbind-modules-4.2.3-10.el7.i686 from rhel-7-server-rpms excluded (updateinfo)
  13. --> tftp-5.2-11.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo)
  14. .
  15. .
  16. 35 package(s) needed for security, out of 115 available
  17. NetworkManager.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
  18. NetworkManager-adsl.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
  19. NetworkManager-bluetooth.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
  20. NetworkManager-config-server.noarch 1:1.12.0-10.el7_6 rhel-7-server-rpms
  21. NetworkManager-glib.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
  22. NetworkManager-libnm.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms
  23. NetworkManager-ppp.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms

列出所有可用的安全补丁,并且显示其详细信息:

  1. # yum info-sec
  2. .
  3. .
  4. ===============================================================================
  5. tzdata bug fix and enhancement update
  6. ===============================================================================
  7. Update ID : RHBA-2019:0689
  8. Release : 0
  9. Type : bugfix
  10. Status : final
  11. Issued : 2019-03-28 19:27:44 UTC
  12. Description : The tzdata packages contain data files with rules for various
  13. : time zones.
  14. :
  15. : The tzdata packages have been updated to version
  16. : 2019a, which addresses recent time zone changes.
  17. : Notably:
  18. :
  19. : * The Asia/Hebron and Asia/Gaza zones will start
  20. : DST on 2019-03-30, rather than 2019-03-23 as
  21. : previously predicted.
  22. : * Metlakatla rejoined Alaska time on 2019-01-20,
  23. : ending its observances of Pacific standard time.
  24. :
  25. : (BZ#1692616, BZ#1692615, BZ#1692816)
  26. :
  27. : Users of tzdata are advised to upgrade to these
  28. : updated packages.
  29. Severity : None

如果你想要知道某个更新的具体内容,可以运行下面这个命令:

  1. # yum updateinfo RHSA-2019:0163
  2.  
  3. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
  4. rhel-7-server-rpms | 2.0 kB 00:00:00
  5. ===============================================================================
  6. Important: kernel security, bug fix, and enhancement update
  7. ===============================================================================
  8. Update ID : RHSA-2019:0163
  9. Release : 0
  10. Type : security
  11. Status : final
  12. Issued : 2019-01-29 15:21:23 UTC
  13. Updated : 2019-01-29 15:23:47 UTC Bugs : 1641548 - CVE-2018-18397 kernel: userfaultfd bypasses tmpfs file permissions
  14. : 1641878 - CVE-2018-18559 kernel: Use-after-free due to race condition in AF_PACKET implementation
  15. CVEs : CVE-2018-18397
  16. : CVE-2018-18559
  17. Description : The kernel packages contain the Linux kernel, the core of any
  18. : Linux operating system.
  19. :
  20. : Security Fix(es):
  21. :
  22. : * kernel: Use-after-free due to race condition in
  23. : AF_PACKET implementation (CVE-2018-18559)
  24. :
  25. : * kernel: userfaultfd bypasses tmpfs file
  26. : permissions (CVE-2018-18397)
  27. :
  28. : For more details about the security issue(s),
  29. : including the impact, a CVSS score, and other
  30. : related information, refer to the CVE page(s)
  31. : listed in the References section.
  32. :
  33. : Bug Fix(es):
  34. :
  35. : These updated kernel packages include also
  36. : numerous bug fixes and enhancements. Space
  37. : precludes documenting all of the bug fixes in this
  38. : advisory. See the descriptions in the related
  39. : Knowledge Article:
  40. : https://access.redhat.com/articles/3827321
  41. Severity : Important
  42. updateinfo info done

跟之前类似,你可以只查询那些通过 CVE 释出的系统漏洞:

  1. # yum updateinfo list cves
  2.  
  3. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  4. : subscription-manager, verify, versionlock
  5. CVE-2018-15688 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64
  6. CVE-2018-15688 Important/Sec. NetworkManager-adsl-1:1.12.0-8.el7_6.x86_64
  7. CVE-2018-15688 Important/Sec. NetworkManager-bluetooth-1:1.12.0-8.el7_6.x86_64
  8. CVE-2018-15688 Important/Sec. NetworkManager-config-server-1:1.12.0-8.el7_6.noarch
  9. CVE-2018-15688 Important/Sec. NetworkManager-glib-1:1.12.0-8.el7_6.x86_64
  10. CVE-2018-15688 Important/Sec. NetworkManager-libnm-1:1.12.0-8.el7_6.x86_64
  11. CVE-2018-15688 Important/Sec. NetworkManager-ppp-1:1.12.0-8.el7_6.x86_64
  12. CVE-2018-15688 Important/Sec. NetworkManager-team-1:1.12.0-8.el7_6.x86_64

你也可以查看那些跟 bug 修复相关的更新,运行下面的命令:

  1. # yum updateinfo list bugfix | less
  2.  
  3. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos,
  4. : subscription-manager, verify, versionlock
  5. RHBA-2018:3349 bugfix NetworkManager-1:1.12.0-7.el7_6.x86_64
  6. RHBA-2019:0519 bugfix NetworkManager-1:1.12.0-10.el7_6.x86_64
  7. RHBA-2018:3349 bugfix NetworkManager-adsl-1:1.12.0-7.el7_6.x86_64
  8. RHBA-2019:0519 bugfix NetworkManager-adsl-1:1.12.0-10.el7_6.x86_64
  9. RHBA-2018:3349 bugfix NetworkManager-bluetooth-1:1.12.0-7.el7_6.x86_64
  10. RHBA-2019:0519 bugfix NetworkManager-bluetooth-1:1.12.0-10.el7_6.x86_64
  11. RHBA-2018:3349 bugfix NetworkManager-config-server-1:1.12.0-7.el7_6.noarch
  12. RHBA-2019:0519 bugfix NetworkManager-config-server-1:1.12.0-10.el7_6.noarch

要想得到待安装更新的摘要信息,运行这个:

  1. # yum updateinfo summary
  2. Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
  3. rhel-7-server-rpms | 2.0 kB 00:00:00
  4. Updates Information Summary: updates
  5. 13 Security notice(s)
  6. 9 Important Security notice(s)
  7. 3 Moderate Security notice(s)
  8. 1 Low Security notice(s)
  9. 35 Bugfix notice(s)
  10. 1 Enhancement notice(s)
  11. updateinfo summary done

如果只想打印出低级别的安全更新,运行下面这个命令。类似的,你也可以只查询重要级别和中等级别的安全更新。

  1. # yum updateinfo list sec | grep -i "Low"
  2.  
  3. RHSA-2019:0201 Low/Sec. libgudev1-219-62.el7_6.3.x86_64
  4. RHSA-2019:0201 Low/Sec. systemd-219-62.el7_6.3.x86_64
  5. RHSA-2019:0201 Low/Sec. systemd-libs-219-62.el7_6.3.x86_64
  6. RHSA-2019:0201 Low/Sec. systemd-sysv-219-62.el7_6.3.x86_64
责任编辑:庞桂玉 来源: Linux中国
相关推荐

2016-12-07 18:12:05

CentOSRHEL安全补丁

2014-07-24 10:17:25

CentOSSquid

2019-06-11 11:50:06

RHELCentOSLinux

2020-11-17 11:19:48

Linux磁盘空间

2020-03-02 14:06:54

CentOS 8FFmpegLinux

2017-04-11 13:20:06

CentOSRHELFedora

2016-01-25 13:03:21

2019-12-02 11:50:09

CentOS 8VirtualBoxLinux

2015-12-21 13:19:23

CentosRHEL 6.XWetty

2017-04-24 18:10:27

DrupalCentOSFedora

2014-08-19 09:33:29

FedoraCentOSRPM

2014-10-11 11:30:43

CentOSDocker

2019-10-12 10:24:06

CentOSRHELCockpit

2023-03-16 08:55:51

RHEL 8MiniKube开源

2019-11-14 09:20:15

CentOS 8RHEL 8Nagios Core

2023-05-29 17:52:29

2019-08-21 14:15:47

DebianUbuntuLinux

2020-04-30 13:50:11

Linux网卡信息

2015-06-01 12:19:03

FedoraCentOSSamba

2014-09-04 09:18:15

点赞
收藏

51CTO技术栈公众号