今天重装VPS的系统,SSH的密码发生改变,重新使用SSH链接服务器时报错。
报错代码:
deisre-deMac:~ hitsujisaruhiroshi$ ssh -l root -p 27714 98.64.108.168
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:e05AhWJxSQjdDADFAGDFGa/x00CKu8/6sEIqQgfcs.
Please contact your system administrator.
Add correct host key in /Users/hitsujisaruhiroshi/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/hitsujisaruhiroshi/.ssh/known_hosts:4
RSA host key for [98.64.108.168]:27714 has changed and you have requested strict checking.
Host key verification failed.
问题原因:
deisre-deMac:.ssh hitsujisaruhiroshi$ ls known_hosts known_hosts.old
known_hosts 是记录远程主机的公钥的文件,之前重装个系统,而保存的公钥还是未重装系统的系统公钥,在 ssh 链接的时候首先会验证公钥,如果公钥不对,那么就会报错。
解决方法:
方法一:删除ssh client 端文件 中对应记录信息即可。
1. 终端输入 vi ~/.ssh/known_hosts
2.键盘输入“i”,切换至输入模式。
3.删除对应记录信息后,使用“Esc”退出输入模式
[98.64.108.168]:27714 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEEWRQWSwg9+LEIvElXiiyO/AixHsIy6uzFmEd5utfEbMNL3IzWmLPfjUNjPsMBLwqerqwereDmeuvH+E8yMi/hC9DUwX4+fTSdfD/KzHneqB6MhhgbMLmni+un7EsagdsfsafsdgVXkoUD0KCD0OoRVDgHXJSw1HcA/W74/XXYX5hZ4DZyG5PqDDuPiO4RDNYDizW4rQKScA+X2YnMADSFA
4.输入“:wq”保存修改记录
5.重新连接SSHdeisre-deMac:~ hitsujisaruhiroshi$ ssh -l root -p 27714 98.64.108.168The authenticity of host '[98.64.108.168]:27714 ([98.64.108.168]:27714)' can't be established.RSA key fingerprint is SHA256:e05AhWJxSQjddJbzLk2B3JHa/x00CKu8/6sEIqQgfcs.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '[98.64.108.168]:27714' (RSA) to the list of known hosts.
6.终端输入yes完成连接
方法二:清除老的公钥信息。
1. 终端输入 ssh-keygen -R 98.64.108.168
#后面填自己服务器的 ip 地址
2.终端显示Host 98.64.108.168 found: line 1 type RSA
3.重新连接SSH
deisre-deMac:~ hitsujisaruhiroshi$ ssh -l root -p 27714 98.64.108.168
The authenticity of host '[98.64.108.168]:27714 ([98.64.108.168]:27714)' can't be established.
RSA key fingerprint is SHA256:e05AhWJxSQjddJbzLk2B3JHa/x00CKu8/6sEIqQgfcs.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[98.64.108.168]:27714' (RSA) to the list of known hosts.
4.终端输入 yes 完成连接
网友评论