2023年1月25日 星期三

ssh 連線出現 remote host identification has changed

原本的 Server IP 已經不是原來的 Server,所以之前初次連線儲存的 key 已不適用,連線時會出現「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 」錯誤。
>ssh 192.168.0.2
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:.............................................
Please contact your system administrator.
Add correct host key in C:\\Users\\xyz/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\xyz/.ssh/known_hosts:1
ECDSA host key for 192.168.0.2 has changed and you have requested strict checking.
Host key verification failed.

提示說明可以到使用者目錄底下的 .ssh/known_hosts 進行修改,比較方便的方式是使用 ssh-keygen 直接刪除該 Server IP 的 key 紀錄。
>ssh-keygen -R 192.168.0.2
# Host 192.168.0.2 found: line 1
C:\Users\xyz/.ssh/known_hosts updated.
Original contents retained as C:\Users\xyz/.ssh/known_hosts.old
刪除後,便可以如初次連線一樣,進行連線。




參考:

沒有留言:

張貼留言