LoginSignup
8
3

More than 3 years have passed since last update.

CentOS Linux 8 でのセキュリティアップデート方法

Posted at

概要

  • CentOS Linux サーバの日々の定常作業として実施するべき dnf upgrade 作業手順をまとめる
  • 通常のパッケージ更新と Linux カーネルのパッケージ更新の2パターン

セキュリティ更新の情報源

セキュリティ情報などの告知メーリングリスト。

CentOS-announce Info Page

CentOS announcements (security and general) will be posted to this list

Red Hat Enterprise Linux 等のセキュリティ勧告ページ。

Red Hat Product Advisories - Red Hat Customer Portal

通常のセキュリティアップデート

実施コマンド概要

新しいバージョンがあるパッケージを更新し、再起動が必要なプロセスを確認する。

$ sudo dnf check-update
$ sudo dnf upgrade
$ sudo needs-restarting

dnf check-update

更新可能なパッケージがあるか確認する。

DNF Command Reference — dnf latest documentation

dnf [options] check-update [--changelogs] [...]

Non-interactively checks if updates of the specified packages are available. If no is given, checks whether any updates at all are available for your system.

dnf upgrade

利用可能な最新のパッケージに更新する。

DNF Command Reference — dnf latest documentation

dnf [options] upgrade
Updates each package to the latest version that is both available and resolvable.

dnf upgrade などにはセキュリティ修正があるパッケージのみを対象とする --security オプションが存在するが、このオプションは Red Hat Enterprise Linux では利用可能だが CentOS では使えない。CentOS ではセキュリティのメタデータを持っていないため使えないとのこと。

CentOS errata : bug and security fixes - CentOS

There is no security metadata in the CentOS yum repos which means that running yum --security update does nothing useful. However, just running yum update applies all outstanding patches including those released for security purposes.

So the answer is: just run yum update

needs-restarting コマンドで再起動が必要なプロセスを確認

needs-restarting を使うためには yum-utils パッケージをインストールする。

$ sudo dnf install yum-utils

needs-restarting コマンドで再起動が必要なプロセスを確認できる。

$ sudo needs-restarting
1 : /usr/lib/systemd/systemd --system --deserialize 21 
554 : /usr/sbin/httpd -DFOREGROUND 
597 : /usr/lib/systemd/systemd-journald 
766 : /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only 
767 : /usr/sbin/mcelog --ignorenodev --daemon --foreground 
769 : /usr/bin/lsmd -d 
770 : /sbin/rngd -f 
777 : /usr/lib/polkit-1/polkitd --no-debug 
779 : /usr/sbin/NetworkManager --no-daemon 
789 : /usr/sbin/chronyd

Linux カーネルのアップデート

コマンド概要

パッケージを更新した後、OS を再起動する必要がある。

$ sudo dnf check-update
$ sudo dnf upgrade
$ sudo reboot

Linux カーネル更新例

$ sudo dnf upgrade
メタデータの期限切れの最終確認: 0:00:11 時間前の 2020年04月15日 08時39分31秒 に実施しました。
依存関係が解決しました。
====================================================================================================
 パッケージ                  Arch   バージョン                                      Repo      サイズ
====================================================================================================
インストール:
 kernel                      x86_64 4.18.0-147.8.1.el8_1                            BaseOS    1.5 M
 kernel-core                 x86_64 4.18.0-147.8.1.el8_1                            BaseOS     25 M
 kernel-devel                x86_64 4.18.0-147.8.1.el8_1                            BaseOS     13 M
 kernel-modules              x86_64 4.18.0-147.8.1.el8_1                            BaseOS     22 M
(中略)
トランザクションの概要
====================================================================================================
インストール     4 パッケージ
アップグレード  61 パッケージ

ダウンロードサイズの合計: 141 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/65): kernel-4.18.0-147.8.1.el8_1.x86_64.rpm                      3.0 MB/s | 1.5 MB     00:00    
(2/65): kernel-devel-4.18.0-147.8.1.el8_1.x86_64.rpm                3.4 MB/s |  13 MB     00:04    
(3/65): kernel-modules-4.18.0-147.8.1.el8_1.x86_64.rpm              3.8 MB/s |  22 MB     00:05    
(中略)
インストール済み:
  kernel-4.18.0-147.8.1.el8_1.x86_64              kernel-core-4.18.0-147.8.1.el8_1.x86_64          
  kernel-devel-4.18.0-147.8.1.el8_1.x86_64        kernel-modules-4.18.0-147.8.1.el8_1.x86_64       

完了しました!

OS を再起動しないと Linux カーネルが更新されない。

$ uname -mrsv
Linux 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64

OSを再起動して、Linux カーネルを更新。

$ sudo reboot

Linux カーネルのバージョンが更新されていることを確認できる。

$ uname -mrsv
Linux 4.18.0-147.8.1.el8_1.x86_64 #1 SMP Thu Apr 9 13:49:54 UTC 2020 x86_64

参考資料

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3