WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 問題解決

今天重裝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 完成連接

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容