ssh 可以ping通但是ssh 或者本地输入账号密码总是错误 删除rsa dsa dcdsa 然后安装openssh-server openssh-client

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

posted on 2018-08-06 17:17  Areon  阅读(629)  评论(0)    收藏  举报

导航