今天重裝VPS的系統(tǒng),SSH的密碼發(fā)生改變,重新使用SSH鏈接服務(wù)器時(shí)報(bào)錯(cuò)。
報(bào)錯(cuò)代碼:
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 是記錄遠(yuǎn)程主機(jī)的公鑰的文件,之前重裝個(gè)系統(tǒng),而保存的公鑰還是未重裝系統(tǒng)的系統(tǒng)公鑰,在 ssh 鏈接的時(shí)候首先會(huì)驗(yàn)證公鑰,如果公鑰不對(duì),那么就會(huì)報(bào)錯(cuò)。
解決方法:
方法一:刪除ssh client 端文件?中對(duì)應(yīng)記錄信息即可。
1. 終端輸入 vi ~/.ssh/known_hosts
2.鍵盤輸入“i”,切換至輸入模式。
3.刪除對(duì)應(yīng)記錄信息后,使用“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
#后面填自己服務(wù)器的 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 完成連接