遠端主機識別已更改

使用 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 RSA key sent by the remote host is
SHA256:L5ri/Xdgpuals893ej1z5F1wlg1n2YNeBf/tsABX+QQ.
Please contact your system administrator.
Add correct host key in /Users/username/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/username/.ssh/known_hosts:12
RSA host key for *IP address* has changed and you have requested strict checking.
Host key verification failed.

這意味著你之前連線到同一伺服器並使用不同的主機金鑰進行識別。如果你知道你更改了伺服器金鑰,重新安裝伺服器或伺服器管理員宣告瞭一些更改,通常可以刪除舊金鑰並讓 ssh 儲存其新密碼。

可以使用 ssh-keygen 透明地刪除舊金鑰:

ssh-keygen -R *IP address*

下一個連線應該要求你驗證新指紋:

ssh192.168.0.128
The authenticity of host '192.168.0.128 (192.168.0.128)' can't be established.
ECDSA key fingerprint is SHA256:L5ri/Xdgpuals893ej1z5F1wlg1n2YNeBf/tsABX+QQ.
Are you sure you want to continue connecting (yes/no)? 

如果你不知道上述任何一項,最好是聯絡你的伺服器管理員以確保一切正常。如果沒有,潛在的攻擊者將能夠獲得你的身份驗證資訊和所有傳輸的資料!