“error: Could not load host key: /etc/ssh/ssh_host_dsa_key”の解決方法

SSHログインする度に、複数のエラーログを吐いていたので対応した。
中でも特に、error: Could not load host key: /etc/ssh/ssh_host_dsa_keyというのがエラーとして赤字で記録されている。この状態でもログインは問題なくできているが、毎回エラーを吐いているというのは気持ちが悪いし後々問題になるかも知れない。

10:42:23 dacelo sshd[36380]: rexec line 54: Deprecated option RSAAuthentication
10:42:23 dacelo sshd[36380]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
10:42:23 dacelo sshd[36380]: reverse mapping checking getaddrinfo for dacelo.info [210.123.456.789] failed - POSSIBLE BREAK-IN ATTEMPT!

Google検索で皆の対応を見てみたところ、「ssh_host_dsa_keyがパスフレーズありになっているので、なしのものに差し替える」という解決法を提示しているページを見かけた。
しかし私の環境には、そもそもssh_host_dsa_keyが存在しない。現在存在しないものをわざわざ作ることもないだろう。ディレクトリ内をよくみてみると、ssh_host_rsa_keyは存在している。
sshd_configを見ると、この辺りの設定が全てコメントアウトされている。

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

この場合、sshdの優先順位として、ssh_host_dsa_keyがデフォルトで使われる。
そこで、明示的に、サーバ内に存在するssh_host_rsa_keyの方を参照するように有効化した。

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

SSHDをリロード。

$ sudo systemctl reload sshd

ステータス確認。

$ sudo systemctl status sshd

これでこのエラーはでなくなりました。解決。

広告

SSHの設定を変更・再起動する際には、現在のセッションを維持したまま、新規セッションが開始できることを確認することを強くおすすめします。

その他のエラーメッセージの対応についてはこちら。
“Deprecated option RSAAuthentication” とメッセージが出たら – DACELO SPACE
SSHログイン時に「POSSIBLE BREAK-IN ATTEMPT!」とメッセージが出たら – DACELO SPACE

About: dacelo


Comments are closed.