ssh接続を使って2つ先にある管理画面Webにアクセスする


下記の様な感じで、踏み台サーバを2つ経由した先にある管理画面Webを、手元の操作端末上のブラウザで確認したい。

sshによるトンネル接続を利用したSOCKS proxyを使うことで実現できる。

構成の概要としては下記の様な形となる。

操作端末はWindows 10で、puttyを使用してssh接続を行い、Firefoxブラウザで管理画面を開く、という想定。

まず、SSH接続1について設定

[Session]-[Host Name] で 踏み台サーバ1 とポート番号を指定(port 22)
[Connection]-[Data]-[Auto-login username] で 踏み台サーバ1のログインユーザ名
[Connection]-[SSH]-[Tunnels]の[Forwarded ports] で 「L10022 踏み台サーバ2:22」(“Local”,”Souce port:10022″,”Destination: 踏み台サーバ2:22″)
公開鍵認証を使用する場合は [Connection]-[SSH]-[Auth]の[Private key file for authentication]に指定

これにより、「踏み台サーバ1へのSSH接続1」と「操作端末のローカルポート10022にアクセスすると踏み台サーバ2のポート22に転送されるトンネル接続」が出来る。

次に作成されたトンネル接続を利用したSSH接続2を設定

[Session]-[Host Name] で localhost ポート 10022 を指定
[Connection]-[Data]-[Auto-login username] で 踏み台サーバ2のログインユーザ名
[Connection]-[SSH]-[Tunnels]の[Forwarded ports] で 「D10080」(“Dynamic”,”Souce port:10080)
公開鍵認証を使用する場合は [Connection]-[SSH]-[Auth]の[Private key file for authentication]に指定

これで「”接続端末のローカルポート10022″から 踏み台サーバ ポート22 に転送されてSSH接続2」と「操作端末のローカルポート 10080 にアクセスすると、踏み台サーバ2 上からネットワーク接続できるトンネル接続」が出来る。

最後に、Firefoxの[General]-[Network Settings]にて、「Manual proxy configuration」で「SOCKS Host: localhost Port: 10080」と設定する。

これで操作端末上から閉鎖網2上にあるWeb管理画面を開けるようになった。


2022/01/20追記

TeraTermでも同様のことを行う手法を調べた。

puttyみたくテンプレート化できないので、ショートカットで起動できるようコマンドラインオプションとして指定する手法とした。

"C:\Program Files (x86)\teraterm\ttermpro.exe" 踏み台サーバ1 /ssh2 /auth=publickey /keyfile=X:\tmp\sshkey\~.ppk /ssh-L10022:踏み台サーバ2:22 /user=踏み台サーバ1のログインユーザ名 /passwd=秘密鍵のパスフレーズ

"C:\Program Files (x86)\teraterm\ttermpro.exe" localhost:10022 /ssh2 /auth=publickey /keyfile=X:\tmp\sshkey\~.ppk /ssh-D10080 /user=踏み台サーバ2のログインユーザ名 /passwd=秘密鍵のパスフレーズ

なお、引数でパスフレーズを指定しない場合、「SSH2秘密鍵の読み込みに失敗しました wrong passphrase」という下記のダイアログが表示されてうざいです。

また、TeraTermでSSHのダイナミックポート転送を行う場合、指定したポートが使用できない場合、下記の様なApplication fault Execption:ACCESS_VIOLATIONダイアログが表示されることがある。

ダイアログもなしにTeraTermが終了することもある。

2022/01/21 追記
TeraTermでのSOCKS proxy(ダイナミックポート転送)がどうにも不安定なので、 puttyで実施している。

Oracle Cloud上のOracle Linux 7インスタンスでyum check-updateを実行した際にELBA-2021-9629,ELBA-2021-9631のメッセージが出力される


Oracle Cloud上のOracle Linux 7インスタンスでyum check-updateを実行したところ、下記の様なメッセージが出力された。

[osakanataro@ocilinux ~]$ sudo yum check-update
読み込んだプラグイン:langpacks, ulninfo
Update notice ELBA-2021-9629 (ol7_developer から) is broken, or a bad duplicate, skipping.
You should report this problem to the owner of the ol7_developer repository.
To help pinpoint the issue, please attach the output of "yum updateinfo --verbose" to the report.
Update notice ELBA-2021-9631 (ol7_developer から) is broken, or a bad duplicate, skipping.
Security: kernel-uek-4.14.35-2047.510.5.2.el7uek.x86_64 is an installed security update
Security: kernel-uek-4.14.35-2047.504.2.el7uek.x86_64 is the currently running version
[osakanataro@ocilinux ~]$

とりあえず、出力にかいてある「yum updateinfo –verbose」を実行してみる。

[osakanataro@ocilinux ~]$ sudo yum updateinfo --verbose
無効になっているため、プラグイン「osmsplugin」は読み込みません
無効になっているため、プラグイン「rhnplugin」は読み込みません
プラグイン「ulninfo」を読み込んでいます
プラグイン「langpacks」を読み込んでいます
Adding en_US.UTF-8 to language list
Config time: 0.091
Yum version: 3.4.3
rpmdb time: 0.000
Setting up Package Sacks
pkgsack time: 0.255
Duplicate of ELBA-2021-9629 differs in some fields:
<<<<<<< ol7_developer:description
'[2.53.1-1]\n- Update to version 2.53.1\n\n[2.53.0-1]\n- Update to version 2.53.0\n\n[2.52.1-1]\n- Update to version 2.52.1\n\n[2.52.0-1]\n- Update to version 2.52.0\n\n[2.51.0-1]\n- Update to version 2.51.0\n\n[2.50.0-1]'
=======
'[2.53.1-1]\n- Update to version 2.53.1'
>>>>>>> ol7_addons:description
Update notice ELBA-2021-9629 (ol7_developer から) is broken, or a bad duplicate, skipping.
You should report this problem to the owner of the ol7_developer repository.
To help pinpoint the issue, please attach the output of "yum updateinfo --verbose" to the report.
Duplicate of ELBA-2021-9631 differs in some fields:
<<<<<<< ol7_developer:description
'[3.4.1-1]\n- Update to version 3.4.1\n\n[3.4.0-1]\n- Update to version 3.4.0\n\n[3.3.3-1]\n- Update to version 3.3.3\n\n[3.3.2-1]\n- Update to version 3.3.2\n\n[3.3.1-1]\n- Update to version 3.3.1\n\n[3.3.0-1]\n- Update to version 3.3.0\n\n[3.2.2-1]\n- Update to version 3.2.2\n\n[3.2.1-1]\n- Update to version 3.2.1\n\n[3.2.0-1]\n- Update to version 3.2.0\n\n[3.1.2-1]\n- Update to version 3.1.2\n\n[3.1.1-1]\n- Update to version 3.1.1\n\n[3.1.0-1]\n- Update to version 3.1.0\n\n[3.0.5-1]\n- Update to version 3.0.5\n\n[3.0.4-1]\n- Update to version 3.0.4\n\n[3.0.3-1]\n- Update to version 3.0.3\n\n[3.0.2-1]\n- Update to version 3.0.2\n\n[3.0.1-1]\n- Update to version 3.0.1\n\n[3.0.0-1]'
=======
'[3.4.1-1]\n- Update to version 3.4.1'
>>>>>>> ol7_addons:description
Update notice ELBA-2021-9631 (ol7_developer から) is broken, or a bad duplicate, skipping.
updateinfo time: 5.586
オブジェクトの更新を構築しています
up:Obs Init time: 4.605
up:simple updates time: 0.024
up:obs time: 0.008
up:condense time: 0.000
updates time: 10.097
Security: kernel-uek-4.14.35-2047.510.5.2.el7uek.x86_64 is an installed security update
Security: kernel-uek-4.14.35-2047.504.2.el7uek.x86_64 is the currently running version
updateinfo summary done
[osakanataro@ocilinux ~]$ 

よくわからん。

該当するErattaは下記と
ELBA-2021-9629 – python-oci-sdk bug fix update
ELBA-2021-9631 – python-oci-cli bug fix update

特に解決につながりそうな情報はない。

レポジトリ一覧を取得してみる

[osakanataro@ocilinux ~]$ 
 yum repolist all
読み込んだプラグイン:langpacks, ulninfo
リポジトリー ID                      リポジトリー名                                                                                               状態
ol7_MODRHCK/x86_64                   Latest RHCK with fixes from Oracle for Oracle Linux 7Server (x86_64)                                         無効
ol7_UEKR3/x86_64                     Latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux 7Server (x86_64)                             無効
ol7_UEKR3_OFED20/x86_64              OFED supporting tool packages for Unbreakable Enterprise Kernel on Oracle Linux 7 (x86_64)                   無効
ol7_UEKR4/x86_64                     Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux 7Server (x86_64)                             無効
ol7_UEKR4_OFED/x86_64                OFED supporting tool packages for Unbreakable Enterprise Kernel Release 4 on Oracle Linux 7 (x86_64)         無効
ol7_UEKR4_archive/x86_64             Unbreakable Enterprise Kernel Release 4 for Oracle Linux 7Server (x86_64) - Archive                          無効
ol7_UEKR5/x86_64                     Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64)                             有効:           592
ol7_UEKR5_RDMA/x86_64                Oracle Linux 7 UEK5 RDMA (x86_64)                                                                            無効
ol7_UEKR5_archive/x86_64             Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64) - Archive                          無効
ol7_UEKR6/x86_64                     Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64)                             無効
ol7_UEKR6_RDMA/x86_64                Oracle Linux 7 UEK6 RDMA (x86_64)                                                                            無効
ol7_addons/x86_64                    Oracle Linux 7Server Add ons (x86_64)                                                                        有効:           579
ol7_developer/x86_64                 Oracle Linux 7Server Development Packages (x86_64)                                                           有効:   1,571+1,295
ol7_developer_EPEL/x86_64            Oracle Linux 7Server EPEL Packages for Development (x86_64)                                                  有効: 28,888+12,373
ol7_developer_UEKR5/x86_64           Oracle Linux 7Server Unbreakable Enterprise Kernel Release 5  Packages for Development and test (x86_64)     無効
ol7_developer_UEKR6/x86_64           Developer Preview of UEK Release 6 (x86_64)                                                                  無効
ol7_developer_kvm_utils/x86_64       Oracle Linux 7Server KVM Utilities for Development and test (x86_64)                                         無効
ol7_developer_php70/x86_64           Oracle Linux 7Server PHP 7.0 Packages for Development and test (x86_64)                                      無効
ol7_developer_php71/x86_64           Oracle Linux 7Server PHP 7.1 Packages for Development and test (x86_64)                                      無効
!ol7_developer_php72/x86_64          Oracle Linux 7Server PHP 7.2 Packages for Development and test (x86_64)                                      無効
ol7_developer_php74/x86_64           Oracle Linux 7Server PHP 7.4 Packages for Development and test (x86_64)                                      有効:           806
ol7_ksplice                          Ksplice for Oracle Linux 7Server (x86_64)                                                                    有効:        19,729
ol7_kvm_utils/x86_64                 Oracle Linux 7Server KVM Utilities (x86_64)                                                                  無効
ol7_latest/x86_64                    Oracle Linux 7Server Latest (x86_64)                                                                         有効:        23,697
ol7_latest_archive/x86_64            Oracle Linux 7Server Latest (x86_64) - Archive                                                               無効
ol7_leapp/x86_64                     Leapp Upgrade Utilities for Oracle Linux 7Server (x86_64)                                                    無効
ol7_optional_archive/x86_64          Oracle Linux 7Server Optional (x86_64) - Archive                                                             無効
ol7_optional_latest/x86_64           Oracle Linux 7Server Optional Latest (x86_64)                                                                有効:        16,690
ol7_security_validation/x86_64       Oracle Linux 7Server Update 3 (x86_64) Security Validations                                                  無効
ol7_software_collections/x86_64      Software Collection Library release 3.0 packages for Oracle Linux 7 (x86_64)                                 有効:        17,074
ol7_u0_base/x86_64                   Oracle Linux 7Server GA installation media copy (x86_64)                                                     無効
ol7_u1_base/x86_64                   Oracle Linux 7Server Update 1 installation media copy (x86_64)                                               無効
ol7_u2_base/x86_64                   Oracle Linux 7Server Update 2 installation media copy (x86_64)                                               無効
ol7_u3_base/x86_64                   Oracle Linux 7Server Update 3 installation media copy (x86_64)                                               無効
ol7_u4_base/x86_64                   Oracle Linux 7Server Update 4 installation media copy (x86_64)                                               無効
ol7_u5_base/x86_64                   Oracle Linux 7Server Update 5 installation media copy (x86_64)                                               無効
ol7_u6_base/x86_64                   Oracle Linux 7Server Update 6 installation media copy (x86_64)                                               無効
ol7_u7_base/x86_64                   Oracle Linux 7Server Update 7 installation media copy (x86_64)                                               無効
ol7_u8_base/x86_64                   Oracle Linux 7Server Update 8 installation media copy (x86_64)                                               無効
ol7_u8_security_validation/x86_64    Oracle Linux 7Server Update 8 (x86_64) Security Validations                                                  無効
ol7_u9_base/x86_64                   Oracle Linux 7Server Update 9 installation media copy (x86_64)                                               無効
ol7_x86_64_userspace_ksplice         Ksplice aware userspace packages for Oracle Linux 7Server (x86_64)                                           無効
packages-microsoft-com-prod          packages-microsoft-com-prod                                                                                  有効:         1,085
repolist: 110,711
[osakanataro@ocilinux ~]$ $ ls /etc/yum.repos.d/
ksplice-ol7.repo               oracle-linux-ol7.repo.20200710      oracle-softwarecollection-ol7.repo.bkp         uek-ol7.repo.20200406
microsoft.repo                 oracle-linux-ol7.repo.bkp           oracle-softwarecollection-ol7.repo.rpmnew.bkp  uek-ol7.repo.bkp
oracle-epel-ol7.repo           oracle-linux-ol7.repo.rpmnew.bkp    oraclelinux-developer-ol7.repo                 uek-ol7.repo.rpmnew.bkp
oracle-epel-ol7.repo.20190815  oracle-php-ol7.repo                 oraclelinux-developer-ol7.repo.20200406        virt-ol7.repo
oracle-epel-ol7.repo.20210217  oracle-php-ol7.repo.20200406        public-yum-ol7.repo.sav                        virt-ol7.repo.bkp
oracle-linux-ol7.repo          oracle-softwarecollection-ol7.repo  uek-ol7.repo                                   virt-ol7.repo.rpmnew.bkp
[osakanataro@ocilinux ~]$

レポジトリがいろいろあるけど、ファイルはもっと多いなぁ・・・なんでだっけ?と記録を漁ったところ2021年6月に行った「Oracle Cloud上の古いOracle Linux 7インスタンスのyum設定を更新する」でのレポジトリ設定更新によるものだった。(Oracle側の記載は 2021.03 – Oracle Linux 7およびOracle Linux 8インスタンスのYumの更新 )

パッケージ情報捜索

ELBA-2021-9629のpython-oci-sdk

[osakanataro@ocilinux ~]$ yum info python-oci-sdk
読み込んだプラグイン:langpacks, ulninfo
利用可能なパッケージ
名前                : python-oci-sdk
アーキテクチャー    : x86_64
バージョン          : 2.36.0
リリース            : 1.el7
容量                : 15 M
リポジトリー        : ol7_developer/x86_64
要約                : Oracle Cloud Infrastructure Python SDK
URL                 : http://pypi.python.org/pypi/oci
ライセンス          : Apache2.0
説明                : Python SDK for Oracle Cloud Infrastructure.

[osakanataro@ocilinux ~]$ rpm -qa|grep oci-sdk
python36-oci-sdk-2.54.0-1.el7.x86_64
[osakanataro@ocilinux ~]$

ELBA-2021-9631のpython-oci-cli

[osakanataro@ocilinux ~]$ yum info python-oci-cli
読み込んだプラグイン:langpacks, ulninfo
利用可能なパッケージ
名前                : python-oci-cli
アーキテクチャー    : noarch
バージョン          : 2.9.0
リリース            : 1.el7
容量                : 1.2 M
リポジトリー        : ol7_developer/x86_64
要約                : Oracle Cloud Infrastructure CLI client
URL                 : http://pypi.python.org/pypi/oci-cli
ライセンス          : Apache2.0
説明                : Python SDK for Oracle Cloud Infrastructure command line client utilities.

[osakanataro@ocilinux ~]$ rpm -qa|grep oci-cli
python36-oci-cli-3.4.2-1.el7.noarch
[osakanataro@ocilinux ~]$

どちらもレポジトリにあるパッケージバージョンより新しいものがインストールされている状態になっている。

そういえば、いつだったかメンテナンスした時に、oci-sdkとoci-cliが古かったのでバージョンアップしたんだっけ、という思い出したので、状況はあるいみ解決した。

https://github.com/oracle/oci-cli/releases

CentOS7,RHEL8,Ubuntu 20.04などでコンソール解像度を低くする


RHEL/CentOS6以降やUbuntu 18.04(?)以降など、最近にLinuxでは起動時に接続しているディスプレイの解像度を認識し、高解像度で表示しようとする。

これは Kernel Mode Setting (KMS) (kernel.orgの説明 / archlinux wikiの説明)の機能により実現されている。

しかし、複数台のサーバを設定する場合、モニタが1台しかないのでつなぎ替えて設定しようとすると、起動時にモニタがつながっていたサーバだけ解像度が高くなってしまう、という弊害がある。

この問題は、DELLサーバに搭載されるiDRAC機能によるリモートコンソール接続の時にも発生してしまい、起動時に物理モニタが接続されているサーバだけブラウザ上のコンソール表示が高解像度で表示されます。

これを避けるには強制的に解像度を指定する必要があります。

参考にした情報源

RedHat KB: RHEL 6 および RHEL 7 で VGA コンソールのテキスト解像度を 80×25 に設定する方法
archlinux wiki: GRUB/ヒントとテクニック の「3.1 フレームバッファの解像度を設定する
grubマニュアル: 6.1 Simple configuration handling
centos.org forum: How to change Grub menu resolution?

Ubuntu 20.04 Serverの場合

インストール直後は、起動直後に下記のようなgrubメニューが表示されない設定となっています。まずは、grubメニューが表示されるよう設定変更してください。(なお、設定手法については後述の /etc/default/grub の所に書いてあります)

grubメニューが表示されるようになったら、上記で止めて「c」を入力し、コマンドラインモードに変更します。

ここで「videoinfo」と入力します。

そうすると対応できる表示モードの一覧が出力されますが、モードが多い場合はスクロールしてしまい、全部を見ることができない場合があります。

そのような場合は「set pager=1」と入力し、そのあとに「videoinfo」を実行します。

なお、日本語キーボード利用時、= は、「^ へ ~」キー(通常の=の右隣)で入力出来ます。

解像度指定は「800x600x32」といったような形で行います。

実際にそれが使用できるかは「videotest 800x600x32」と実行します。

そうすると、下記の様に表示されます。これが読める状態であれば問題ありません。

このテストは終了する手法がないため、強制再起動します。(ctrl+alt+deleteなどで)

設定する解像度が決まったら普通にUbuntuを起動します。

設定するファイルは /etc/default/grub です。

Ubuntu 20.04をvSphere上でインストールした場合の初期値では下記の様になっていました。

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

grubメニューを表示して10秒まつ設定(“GRUB_TIMEOUT_STYLE=menu”と”GRUB_TIMEOUT=10” ) を入れて

そこに、コンソール解像度を設定するための以下の設定を入れます。

grubでの解像度を指定するための「GRUB_GFXMODE=800×600」
grubでの設定内容をkernel起動後も維持するための「GRUB_GFXPAYLOAD_LINUX=keep」と、「GRUB_CMDLINE_LINUX_DEFAULT=」行への「nomodeset」追加

これを行った後の /etc/default/grub の内容は下記の様になります。

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity nomodeset"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
GRUB_GFXMODE=800x600
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

書き換えたらgrub.cfgを生成するため「sudo update-grub2」を実行します。

instadmin@ubuntu:~$ sudo update-grub2
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-91-generic
Found initrd image: /boot/initrd.img-5.4.0-91-generic
done
instadmin@ubuntu:~$

設定後、再起動して解像度が指定通りになっていることを確認します。

CentOS7の場合

RedHatのKBに記載があります:「RHEL 6 および RHEL 7 で VGA コンソールのテキスト解像度を 80×25 に設定する方法

上記KBでは640×480に設定していますが、他の解像度が指定できないものかCentOS7でいろいろ試してみましたが出来ませんでした。

設定は /etc/default/grub に行います。

CentOS7をvSphere環境上にインストールした場合、下記の様になっていました。

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap"
GRUB_DISABLE_RECOVERY="true"

この「GRUB_CMDLINE_LINUX=」行に「video=640×480」と「nomodeset」の両方を追加します。

RedHat KBではvideoだけでもいけるようなことを書いていましたが、実サーバ(DELL PowerEdge R640 UEFI設定)では問題なかったものの、vSphere仮想環境(BIOS設定)では起動途中で解像度が変わる動作をしたため「nomodeset」を追加しています。

ただ、KBにはnomodesetは悪、的な記述もあるので、ダメだったら追加する、ぐらいの方がいいかもしれません

追加後は以下の様な形になります。

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap video=640x480 nomodeset"
#GRUB_GFXMODE=800x600x24
GRUB_DISABLE_RECOVERY="true"

EFI環境の場合「grub2-mkconfig -o /etc/grub2-efi.cfg」、BIOS環境の場合「grub2-mkconfig -o /etc/grub2.cfg」を実行してgrub設定を更新します。

[root@centos7 ~]# grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-2c896cb2eafd4db586ecfbd67535d5dc
Found initrd image: /boot/initramfs-0-rescue-2c896cb2eafd4db586ecfbd67535d5dc.img
done
[root@centos7 ~]#

この後、再起動して解像度が設定されていることを確認します。

参考情報

CentOS7の場合、Ubuntu 20.04と異なり、grubでのvideoinfo/videotestコマンドがなく、vdeinfo/vbetestコマンドとなります。

参考として、下記にCentOS7での実行の様子を記載します。

grubメニューで止めて、「c」を入力し、コマンドラインモードに入ります。

CentOS7の場合はvideoinfoが搭載されていないgrubなので「vbeinfo」を実行します。

CentOS7の場合は set pager=1 の設定がされているようで出力が多い場合でも表示を止めてくれます。

表示テストは「vbetest 800x600x32」といった形で実施します。(おなじくvideotestコマンドが無い)

vbetestの終了は強制再起動(ctrl+alt+deleteなど)を行います。

Oracle Linux 8の場合(2021/12/08)

/etc/default/grub にいろいろ記述を入れてみてるのですが、解像度変更ができる気配がない・・・

また、grubでのvideoinfo, vbeinfo, videotest, vbetest はない模様

RHEL 8.6/Oracle Linux 8.6の場合(2022/07/11)

/etc/default/grubのGRUB_CMDLINE_LINUXに「video=800×600」を追加してみたところ、それっぽく動いている。

なお、去年試した時と同じくgrubでのvideoinfo, vbeinfo, videotest, vbetest は存在していないようだ。

/etc/default/grubのGRUB_CMDLINE_LINUXに「video=1024×768」を追加でも大丈夫だった。

Oracle Linux 8でphp 7.4.19-1にアップデート後からphp-fpmが起動しなくなった


Oracle Cloud上にARMインスタンスをたててOracle Linux 8をインストールしてwordpressサーバの運用を開始した。

ところが今日の朝実行された dnf automaticによる自動更新後、wordpressが「Service Unavailable」となり表示出来ない。

sshログインして確認するとphp-fpmが起動していない。

[root@retoge ~]# systemctl status php-fpm|cat
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2021-11-18 09:25:41 JST; 16s ago
  Process: 482320 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=127)
 Main PID: 482320 (code=exited, status=127)

Nov 18 09:25:41 retoge systemd[1]: Starting The PHP FastCGI Process Manager...
Nov 18 09:25:41 retoge php-fpm[482320]: /usr/sbin/php-fpm: error while loading shared libraries: cannot restore segment prot after reloc: Permission denied
Nov 18 09:25:41 retoge systemd[1]: php-fpm.service: Main process exited, code=exited, status=127/n/a
Nov 18 09:25:41 retoge systemd[1]: php-fpm.service: Failed with result 'exit-code'.
Nov 18 09:25:41 retoge systemd[1]: Failed to start The PHP FastCGI Process Manager.
[root@retoge ~]#

SELinuxの問題で起動していなさそうなので/var/log/audit/audit.log を確認してみると下記の出力があった。

type=AVC msg=audit(1637195141.234:5827): avc:  denied  { execmod } for  pid=482320 comm="php-fpm" path="/usr/sbin/php-fpm" dev="dm-0" ino=369761 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_exec_t:s0 tclass=file permissive=0

type=SERVICE_START msg=audit(1637195141.238:5828): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=php-fpm comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'^]UID="root" AUID="unset"

関連していそうなファイルのセキュリティコンテキストを確認

[root@retoge ~]# ls -lZ /usr/sbin/php-fpm
-rwxr-xr-x. 1 root root system_u:object_r:httpd_exec_t:s0 4656056 Oct 12 18:47 /usr/sbin/php-fpm
[root@retoge ~]# restorecon -R -v /usr/sbin
[root@retoge ~]# ls -lZ /usr/sbin/php-fpm
-rwxr-xr-x. 1 root root system_u:object_r:httpd_exec_t:s0 4656056 Oct 12 18:47 /usr/sbin/php-fpm
[root@retoge ~]# ls -lZ /usr/lib/systemd/systemd
-rwxr-xr-x. 1 root root system_u:object_r:init_exec_t:s0 1528680 Nov 11 09:41 /usr/lib/systemd/systemd
[root@retoge ~]# restorecon -R -v /usr/lib
[root@retoge ~]# ls -lZ /usr/lib/systemd/systemd
-rwxr-xr-x. 1 root root system_u:object_r:init_exec_t:s0 1528680 Nov 11 09:41 /usr/lib/systemd/systemd
[root@retoge ~]#

特に問題はなさそう?

ぐぐった時に出てきた「Bug 1670386 – AVC denied httpd_execmem for php-fpm when php-opcache is installed」が近いかな?と httpdのhttpd_execmemをonに変えてみたけど、これだけではダメな模様(後述のaudit2allowの結果を見ると、これ自体は必要そうでした)

[root@retoge ~]# getsebool httpd_execmem
httpd_execmem --> off
[root@retoge ~]# setsebool -P httpd_execmem on
[root@retoge ~]# getsebool httpd_execmem
httpd_execmem --> on
[root@retoge ~]# 
[root@retoge ~]# systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xe" for details.
[root@retoge ~]# systemctl restart httpd
[root@retoge ~]# systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xe" for details.
[root@retoge ~]#

今回はとりあえずphp-fpmが動けばいいか、ということで、問題となっているものを無視して起動できるようにしてしまうことにした。

まず、ausearchコマンドで関係するものをピックアップして、audit2allowで作成される予定のルールを確認する。

[root@retoge ~]# ausearch -m AVC |grep php| audit2allow


#============= httpd_t ==============

#!!!! This avc is allowed in the current policy
allow httpd_t http_port_t:tcp_socket name_connect;
allow httpd_t httpd_exec_t:file execmod;

#!!!! This avc can be allowed using the boolean 'httpd_unified'
allow httpd_t httpd_sys_content_t:dir write;

#!!!! This avc can be allowed using the boolean 'httpd_unified'
allow httpd_t httpd_sys_content_t:file write;
[root@retoge ~]#

これをモジュール化して組み込みます。

[root@retoge ~]# ausearch -m AVC |grep php| audit2allow -M php-fpm
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i php-fpm.pp

[root@retoge ~]# ls -l php-fpm*
-rw-r--r--. 1 root root 1594 Nov 18 09:51 php-fpm.pp
-rw-r--r--. 1 root root  597 Nov 18 09:51 php-fpm.te
[root@retoge ~]#

[root@retoge ~]# semodule -l |grep php
[root@retoge ~]# semodule -i php-fpm.pp
[root@retoge ~]# semodule -l |grep php
php-fpm
[root@retoge ~]#

php-fpmを起動してみます。

[root@retoge ~]# systemctl start php-fpm
[root@retoge ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-11-18 09:53:45 JST; 5s ago
 Main PID: 489019 (php-fpm)
   Status: "Ready to handle connections"
    Tasks: 6 (limit: 36876)
   Memory: 24.1M
   CGroup: /system.slice/php-fpm.service
           tq489019 php-fpm: master process (/etc/php-fpm.conf)
           tq489020 php-fpm: pool www
           tq489021 php-fpm: pool www
           tq489022 php-fpm: pool www
           tq489023 php-fpm: pool www
           mq489024 php-fpm: pool www

Nov 18 09:53:45 retoge systemd[1]: Starting The PHP FastCGI Process Manager...
Nov 18 09:53:45 retoge systemd[1]: Started The PHP FastCGI Process Manager.
[root@retoge ~]#

正常に起動が成功し、wordpressの動作も正常となりました。


2022/01/20追記

放置していたサーバでも発生していたので対処したところ、httpd_execmem有効化とselinuxモジュール追加で動き出しました

[root@retoge ~]# getsebool httpd_execmem
httpd_execmem --> off
[root@retoge ~]# setsebool -P httpd_execmem on
[root@retoge ~]# getsebool httpd_execmem
httpd_execmem --> on
[root@retoge ~]# ausearch -m AVC |grep php |audit2allow


#============= httpd_t ==============
allow httpd_t httpd_exec_t:file execmod;
[root@retoge ~]# ausearch -m AVC |grep php |audit2allow -M php-fpm
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i php-fpm.pp
[root@retoge ~]# semodule -i php-fpm.pp
[root@retoge ~]# systemctl start php-fpm
[root@retoge ~]#

Firewall内のCentOSからhttps://mirror.centos.org/にアクセスできなかった件


FortigateによるFirewall内にあるCentOS9サーバから「dnf check-update」を実行してみたところ、失敗した。

[root@centos9 ~]# dnf update
サブスクリプション管理リポジトリーを更新しています。
コンシューマー識別子を読み込めません

このシステムは、エンタイトルメントサーバーに登録されていません。subscription-manager で登録できます。

CentOS Stream 9 - BaseOS                        0.0  B/s |   0  B     00:03
Errors during downloading metadata for repository 'baseos':
  - Curl error (60): SSL peer certificate or SSH remote key was not OK for https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http [SSL certificate problem: self-signed certificate in certificate chain]
エラー: repo 'baseos' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: Curl error (60): SSL peer certificate or SSH remote key was not OK for https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http [SSL certificate problem: self-signed certificate in certificate chain]
[root@centos9 ~]#

内容的には https://mirrors.centos.org/ へのアクセスでエラーになっていたので、curlコマンドで状況を確認してみることにした。

[root@centos9 ~]# curl -vvv https://mirrors.centos.org/publiclist/
*   Trying 13.125.120.8:443...
* Connected to mirrors.centos.org (13.125.120.8) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
*  CAfile: /etc/pki/tls/certs/ca-bundle.crt
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS header, Unknown (21):
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self-signed certificate in certificate chain
* Closing connection 0
curl: (60) SSL certificate problem: self-signed certificate in certificate chain
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
[root@centos9 ~]#

同じ環境にあるCentOS7サーバやOracle Linux8サーバでも同じ結果になった。

他の環境にあるCentOS7サーバで実行してみると下記のような感じになった。

-bash-4.2$ curl -vvv https://mirrors.centos.org/publiclist/
* About to connect() to mirrors.centos.org port 443 (#0)
*   Trying 2620:52:3:1:dead:beef:cafe:fed6...
* Connected to mirrors.centos.org (2620:52:3:1:dead:beef:cafe:fed6) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=mirrors.centos.org
*       start date: 10月 19 06:06:54 2021 GMT
*       expire date:  1月 17 06:06:53 2022 GMT
*       common name: mirrors.centos.org
*       issuer: CN=R3,O=Let's Encrypt,C=US
> GET /publiclist/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: mirrors.centos.org
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Fri, 12 Nov 2021 08:44:59 GMT
< Server: Apache
< X-Frame-Options: SAMEORIGIN
< X-Xss-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Referrer-Policy: same-origin
< Location: https://admin.fedoraproject.org/mirrormanager/
< Content-Length: 299
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://admin.fedoraproject.org/mirrormanager/">here</a>.</p>
<hr>
<address>Apache Server at mirrors.centos.org Port 443</address>
</body></html>
* Connection #0 to host mirrors.centos.org left intact
-bash-4.2$

Let’s Encryptの証明書使ってるな、ということで、同じ環境にあるブラウザからアクセスしてみると、Fortigateによるhttps周りの動作の問題であることが判明

解決方法は「FortiGate環境で”This Connection is Invalid. SSL certificate expired.”を食らった」にあるやつと同じでした。