OpenSSH服务器报错 Could not load host key

时间:2019-08-20 17:58:10  来源:igfitidea点击:

在升级OpenSSH服务器后,报错"无法加载主机密钥":

Jan 23 11:14:22 localhost sshd[6296]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Jan 23 11:15:05 localhost sshd[6671]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Jan 23 11:15:05 localhost sshd[6671]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

解决方法

我们有几种方法来解决这个问题。

这里,我们将删除所有密钥并重新启动sshd服务。

首先备份整个/etc/ssh目录。

tar -cvzf etc_ssh.tar.gz /etc/ssh

现在列出这些文件一次,确认有多少个ssh密钥。

[root@localhost ssh]# ls -l /etc/ssh/ssh*key
-rw-------. 1 root root  668 Jan 23 11:23 /etc/ssh/ssh_host_dsa_key
-rw-------. 1 root root  227 Jan 23 11:23 /etc/ssh/ssh_host_ecdsa_key
-rw-------. 1 root root  419 Jan 23 11:23 /etc/ssh/ssh_host_ed25519_key
-rw-------. 1 root root  991 Jan 23 11:23 /etc/ssh/ssh_host_key
-rw-------. 1 root root 1675 Jan 23 11:23 /etc/ssh/ssh_host_rsa_key
[root@localhost ssh]#

删除密钥文件

rm /etc/ssh/ssh*key

重新启动ssh服务

systemctl restart ssh