Last Updated on 2021-10-11 by Clay
如果在使用 ssh 指令連線到遠端伺服器時,遇到了以下的問題從而導致無法連線:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:wruvASsAzradn/Acy0g0YwuDGBZb7ierhmL/fhhsSu4.
Please contact your system administrator.
Add correct host key in /Users/clay/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/clay/.ssh/known_hosts:13
ECDSA host key for ohio.cs.nccu.edu.tw has changed and you have requested strict checking.
Host key verification failed.
請不要緊張,雖然上面很嚴重地寫著你的系統可能遭到入侵,但實際上很多時候,可能是因為我們過去曾經連線過這台遠端的伺服器,並將其加入了 known_hosts 中,但是遠端伺服器可能重灌了或是做了某些設定的修改,導致現在通過 ssh 指令連線上會出現警告訊息。
解方方法
如果真的想要快速連線,很簡單的方法就是直接使用 root 權限下 ssh 指令;但若是不希望每次連線都要做同樣的事情,那麼可以前往 known_hosts 將其有遠端主機 IP 的那行刪除。
或是將整個 known_hosts 刪除也沒關係。
References
- https://www.digitalocean.com/community/questions/how-can-i-get-rid-of-warning-remote-host-identification-has-changed
- https://stackabuse.com/how-to-fix-warning-remote-host-identification-has-changed-on-mac-and-linux/