@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
08:70:a2:d1:8c:a8:e2:a3:75:27:b5:90:ce:54:5b:3d.
Please contact your system administrator.
Add correct host key in /Users/henry/.ssh/known_hosts to get rid of this message.
Offending key in /Users/henry/.ssh/known_hosts:2
RSA host key for 66.105.230.188 has changed and you have requested strict checking.
Host key verification failed.
ssh-keygen -R 66.105.230.188
# 輸出:/Users/henry/.ssh/known_hosts updated.
# Original contents retained as /Users/henry/.ssh/known_hosts.old
vi ~/.ssh/known_hosts
# 找到第 2 行 (Offending key:2) 或包含 66.105.230.188 的行
# 刪除該行 (dd)
# 存檔離開
sed -i '/66.105.230.188/d' ~/.ssh/known_hosts
ssh root@66.105.230.188
# 首次會提示新金鑰指紋確認
The authenticity of host '66.105.230.188' can't be established.
RSA key fingerprint is SHA256:xxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
# 輸入 yes,寫入新金鑰
| 設定 | 行為 | 安全性 |
|---|---|---|
StrictHostKeyChecking ask (預設) | 首次詢問、變更報錯阻擋 | 高 |
StrictHostKeyChecking no | 自動接受新金鑰、不檢查 | 低 (易受 MITM) |
StrictHostKeyChecking yes | 嚴格檢查、不在 known_hosts 拒絕連線 | 最高 |
# 臨時跳過檢查 (僅信任網路環境使用)
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@host
# 永久配置 ~/.ssh/config
Host *
StrictHostKeyChecking ask
UserKnownHostsFile ~/.ssh/known_hosts
ssh-keyscan 預先收集金鑰分發給團隊:ssh-keyscan -t rsa,ecdsa,ed25519 66.105.230.188 >> known_hostsUpdateHostKeys yes (OpenSSH 6.8+) 自動更新輪換金鑰PuTTY 會彈出視窗提示金鑰變更,點選「是」更新快取即可。或在 Registry 清除:
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys