1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

centos7.6 にて sshd が起動しない(Failed to start OpenSSH server daemon)

Posted at

■環境

OS:CentOS Linux release 7.6.1810 (Core)
SSH:openssh-server-7.4p1-16.el7.x86_64

■症状

OSインストール直後に確認された症状になります。

①SSHサービスが起動していない。

image.png

log
Dec 31 10:24:27 cent76-zc6 systemd: sshd.service holdoff time over, scheduling restart.
Dec 31 10:24:27 cent76-zc6 systemd: Stopped OpenSSH server daemon.
Dec 31 10:24:27 cent76-zc6 systemd: Starting OpenSSH Server Key Generation...
Dec 31 10:24:27 cent76-zc6 kernel: traps: ssh-keygen[6421] trap invalid opcode ip:7ffb8a169fff sp:7ffddf387db8 error:0 in libcrypto.so.1.0.2k[7ffb8a091000+234000]
Dec 31 10:24:27 cent76-zc6 sshd-keygen: Generating SSH2 RSA host key: /usr/sbin/sshd-keygen: 52 行:  6421 Illegal instruction     $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' &>/dev/null
Dec 31 10:24:27 cent76-zc6 sshd-keygen: [失敗]
Dec 31 10:24:27 cent76-zc6 systemd: sshd-keygen.service: main process exited, code=exited, status=1/FAILURE
Dec 31 10:24:27 cent76-zc6 systemd: Failed to start OpenSSH Server Key Generation.
Dec 31 10:24:27 cent76-zc6 systemd: Unit sshd-keygen.service entered failed state.
Dec 31 10:24:27 cent76-zc6 systemd: sshd-keygen.service failed.
Dec 31 10:24:27 cent76-zc6 systemd: Starting OpenSSH server daemon...
Dec 31 10:24:27 cent76-zc6 sshd: Could not load host key: /etc/ssh/ssh_host_rsa_key
Dec 31 10:24:27 cent76-zc6 sshd: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Dec 31 10:24:27 cent76-zc6 sshd: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Dec 31 10:24:27 cent76-zc6 sshd: sshd: no hostkeys available -- exiting.
Dec 31 10:24:27 cent76-zc6 systemd: sshd.service: main process exited, code=exited, status=1/FAILURE
Dec 31 10:24:27 cent76-zc6 systemd: Failed to start OpenSSH server daemon.
Dec 31 10:24:27 cent76-zc6 systemd: Unit sshd.service entered failed state.
Dec 31 10:24:27 cent76-zc6 systemd: sshd.service failed.

/etc/sshディレクトリに鍵ファイルがない。

image.png

正常に動作する際には以下の鍵ファイルが存在しています。
image.png

ssh-keygenコマンドが失敗する。

Illegal instructionといった内容が表示されコマンドが失敗します。
image.png

■解決策

yum updateを利用しパッケージアップデートを行います。

手順① yum.confファイルの編集

OS自体のバージョンを上げないため、yum.confファイルに以下を追記します。

yum.conf
# vi /etc/yum.conf
---------------------
exclude=centos-release* kernel*
---------------------

redhat系の場合は以下とします。
exclude=redhat-release* kernel*

手順② パッケージ更新

以下コマンドでパッケージ更新を行います。

update
# yum update -y

手順③ サービス確認

サービス起動状態を確認します。

service
# systemctl status sshd

■うまくいかなかったこと

①OS再起動

reboot
# shutdown -r now

→効果なし

②ssh関連パッケージの更新

update
# yum update -y openssh*

→効果なし

③ssh関連パッケージのアンインストール、インストール

update
# yum remove -y openssh*
# yum install -y openssh*

→効果なし

■その他

何かのパッケージが古い or 依存性のあるパッケージが足りていない可能性がありますが、デバッグするほどの余力がないのでここまで。
(余裕があればパッケージ一覧のbefore/afterでdiffしつつ、怪しいパッケージをupdate/installして確認していけば特定できる気がする (無限に時間があれば)

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?