症状:


# /usr/sbin/sshd


系统提示“Could not load host key: /etc/ssh/ssh_host_key


Could not load host key: /etc/ssh/ssh_host_rsa_key


Could not load host key: /etc/ssh/ssh_host_dsa_key


Disabling protocol version 1. Could not load host key


Disabling protocol version 2. Could not load host key


sshd: no hostkeys available — exiting”


大致的意思就是需要某个key什么的。


解决办法如下:


#ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key


Generating public/private dsa key pair.


Enter passphrase (empty for no passphrase):


Enter same passphrase again:


Your identification has been saved in /etc/ssh/ssh_host_dsa_key.


Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.


The key fingerprint is:


xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx root@localhost.localdomain


#ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key


Generating public/private rkey pair.


Enter passphrase (empty for no passphrase):


Enter same passphrase again:


Your identification has been saved in /etc/ssh/ssh_host_rsa_key.


Your public key has been saved in /etc/ssh/ssh_host_dsa_rey.pub.


 (一路回车,不要输入密码)


重启ssh,完成


我是输入命令/etc/init.d/ssh start后出现提示:


Could not load host key: /etc/ssh/ssh_host_dsa_key


然后直接输入ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key


重启ssh,然后就好了