本文介紹使用SSH遠程連接Linux系統的ECS實例時,提示“Host key verification failed”的錯誤原因和解決方案。
問題現象
本地客戶端為Linux環境或macOS環境,使用SSH方式無法正常連接Linux系統的ECS實例時,提示如下錯誤信息。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 ae:6e:68:4c:97:a6:91:81:11:38:8d:64:ff:92:13:50. 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:70 RSA host key for x.x.x.x has changed and you have requested strict checking. Host key verification failed.
本地客戶端為Windows環境,使用常見的SSH客戶端(如Putty或MobaXterm)連接Linux系統的ECS實例時,提示類似“The host key does not match the one Putty has cached for this server”或“remote server identification has changed”錯誤信息。
問題原因
該ECS實例可能進行過重裝系統、賬戶信息變更等操作,導致ECS實例SSH公鑰變更,造成本地客戶端保存的公鑰指紋與服務器端不一致,出現該提示信息。
解決方案
您可以根據本地客戶端環境不同,選擇合適的方案。
本地客戶端為Windows環境
本文以SSH客戶端Putty和MobaXterm進行介紹,不同SSH客戶端操作有所差異,請根據實際的客戶端進行操作。
客戶端為Putty時,單擊Accept,Putty會自動更新密鑰指紋信息,即可成功登錄實例。
客戶端為MobaXterm時,單擊Accept the new server hostkey and carry on connecting
,MobaXterm會自動更新密鑰指紋信息,即可成功登錄實例。
本地客戶端為Linux或macOS環境
在本地客戶端中,執行如下命令,進入對應賬號的
known_hosts
文件。vim ~/.ssh/known_hosts
按
i
鍵進入編輯模式。刪除ECS實例IP對應的條目,如下圖所示。
按
Esc
鍵,輸入:wq
保存并退出。重新連接Linux實例,確保可以正常連接。
文檔內容是否對您有幫助?