您的位置:首页 > 运维架构 > Linux

Could not load host key: /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key问题

2011-12-12 22:55 507 查看
Could not load host key: /etc/ssh/ssh_host_rsa_key

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

问题的解决

症状:
用命令/usr/sbin/sshd启动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什么的。
问题所在:
    1、系统丢失了ssh_host_dsa_key和ssh_host_rsa_key
    2、用户没有权限访问这两个key

解决办法如下:
1、系统丢失了两个key时:

在终端中输入:ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key重新建立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重新建立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.
root@localhost.localdomain
现在用

/usr/sbin/sshd
即可成功启动sshd

这时候,就可以在windows底下使用putty连接这台linux主机了。
2、当前用户没有权限的时候用命令
/usr/sbin/sshd
启动sshd的时候也会这样,所以这是检查是否是root用户,一般root用户才能执行这个操作
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ssh 终端 windows linux