ssh連線遠端伺服器出現Host key verification failed. lost connection問題的解決

一許流星發表於2018-10-14

1.問題如下:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:UggbFShWZWxVBwyKHyYcCIkTNsl+r9Awg8Mv0E7mq5c.
Please contact your system administrator.
Add correct host key in /home/python/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/python/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/home/python/.ssh/known_hosts" -R 39.108.71.7
ECDSA host key for 39.108.71.7 has changed and you have requested strict checking.
Host key verification failed.
lost connection

2.原因分析

    在主機子系統每次成功ssh連線遠端操作,都會把你每個你訪問過計算機的公鑰(public key)都記錄在主機的目錄/Users/icarus/.ssh/known_hosts下,當下次訪問相同子機伺服器時,會核對公鑰。如果公鑰不同,會發出警告,避免你受到DNS Hijack之類的攻擊。

3.解決方法 

進入目錄刪除檔案即可,然後重新連線就能發現連線上了。

cd  ~/.ssh/
rm  known_hosts

即可完美解決!

如果你和我有共同愛好,我們可以加個好友一起交流哈!

 

相關文章