注释:
用过ssh的朋友们应该有注意到,首次通过ssh访问新环境时都会提示“Are you sure you want to continue connecting (yes/no)?”,第二次再连接就不会有该提示;正因如下原因
ssh默认会把你每个你访问过计算机的公钥(public key)都记录在/root/.ssh/known_hosts。当再次访问该主机时,OpenSSH会校对公钥,公钥相同直接连接无如上提示;如果公钥不同,OpenSSH则发出警告, 避免你受到DNS Hijack之类的攻击。
报错信息:
[root@zabbix-server data]# scp scripts/index.html 10.240.1.14:/root
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed. -->原因
The fingerprint for the RSA key sent by the remote host is
f0:7b:32:a5:5a:84:50:fd:2a:de:9c:e6:6e:7c:52:bb.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:15 -->行号
RSA host key for 10.240.1.14 has changed and you have requested strict checking.
Host key verification failed.
lost connection
[root@zabbix-server data]#
原因:
远程10.240.1.14 公钥有改变,导致zabbix-server本地OPENSSH 校对公钥失败。
解决方案:
1)手动删除 /root/.ssh/known_hosts 文件 对应远程IP信息(vi /root/.ssh/known_hosts ---> 错误公钥信息 执行dd 再:wq 即可.)
2)命令删除 ssh-keygen -R 10.240.1.14
[root@Database-backup BACKUP]# ssh-keygen -R 10.240.1.14
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@Database-backup BACKUP]#
3)配置文件“~/.ssh/config” ,加上下面两行来实现scp 不做known_hosts验证,重启服务器。
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
** 建议方案3 SSH登陆时会忽略known_hsots文件,不安全。
扩展:
查看本地/root.ssh/known_hosts某IP公钥信息命令:ssh-keygen -F IP
【源于本人笔记】 若有书写错误,表达错误,请指正...
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28602568/viewspace-1779455/
,如需转载,请注明出处,否则将追究法律责任。