SSH 連線時出現 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 時怎麼辦?
SSH連線
3 min readMar 24, 2023
當你在 SSH 連線時,例如下面這樣操作:
chunlicheng@MacBook-Air-M1 ~ % ssh jack@192.168.1.99
卻出現下面這樣的錯誤:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 ED25519 key sent by the remote host is
SHA256:
Please contact your system administrator.
Add correct host key in /Users/chunlicheng/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/chunlicheng/.ssh/known_hosts:23
Host key for 192.168.1.99 has changed and you have requested strict checking.
Host key verification failed.
這段訊息大致是說 key 已經變了,但你電腦中的 key 還是舊的,這時候我們就鍵入如下:
ssh-keygen -R 192.168.1.99
清掉舊的 key
,接著再次登入就會出現如下:
The authenticity of host '192.168.1.99 (192.168.1.99)' can't be established.
ED25519 key fingerprint is SHA256:
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
ED25519 是 key type,這時候鍵入 yes
就可以順利登入了。
Reference: