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

来源:互联网 发布:python cuda dlib 编辑:程序博客网 时间:2024/05/23 02:01

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用户才能执行这个操作