工作当中遇到的ssh错误

时间:2024-01-09 16:56:20

[root@1bcc1d3f9666 externalscripts]# /usr/sbin/sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key        解决参考:http://blog.csdn.net/hyholine/article/details/7362073
Could not load host key: /etc/ssh/ssh_host_ecdsa_key                   解决命令: ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key(https://linux.cn/article-4226-1.html)
Could not load host key: /etc/ssh/ssh_host_ed25519_key               解决命令:cd /etc/ssh  && ssh-keygen -A
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

解决linux中ssh登录Warning:Permanently added (RSA) to the list of known hosts

远程登录==>

[root@i-nbje0lea .ssh]# ssh 192.168.9.10
Warning: Permanently added '192.168.9.10' (RSA) to the list of known hosts.
Last login: Fri Sep 25 15:37:49 2015 from 192.168.9.11

报Warning:Permanently added (RSA) to the list of known hosts错误

因:在执行ssh 时,没在本机的~/.ssh下生成known_hosts文件。

解决方案:
# vi/etc/ssh/ssh_config         //注意是客户端设置文件
最后有两行是
        StrictHostKeyChecking no             #登录时是否询问
        UserKnownHostsFile /dev/null     #表示隐藏known_hosts文件

两行解释如下:

StrictHostKeyChecking

If this flag is set to “yes”, ssh(1) will never automatically add host keys to the
             ~/.ssh/known_hosts file, and refuses to connect to hosts whose host key has changed.The default is “ask”.

UserKnownHostsFile
             Specifies a file to use for the user host key database instead of ~/.ssh/known_hosts.
把这两行注释掉并保存文件
再次执行ssh 192.168.9.10
出现提示

[admin@i-nbje0lea .ssh]$ ssh 192.168.9.10
The authenticity of host '192.168.9.10 (192.168.9.10)' can't be established.
RSA key fingerprint is 50:e9:44:87:86:c3:0f:85:ab:41:5e:33:1e:5b:6a:c1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.9.10' (RSA) to the list of known hosts.
Last login: Fri Sep 25 15:27:34 2015 from 192.168.9.11

输入yes后,则可看到在/root/.ssh目录下生成了known_hosts文件:

[root@host100.ssh]# ls
id_rsa  id_rsa.pub  known_hosts