SSH 客戶端嚴格檢查服務端 Host Key,VPS 重裝系統/換 IP/換密鑰對後,已知主機列表與新指紋不匹配,觸發嚴重警告並拒絕連接。本文給出標準修復命令與原理說明。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
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.
核心提示:known_hosts 第 2 行舊指紋與新服務器不符。
ssh-keygen -R 66.105.230.188
自動備份並移除該主機所有相關記錄 (IP/域名/別名)。
vi ~/.ssh/known_hosts (Windows 用戶路徑為 C:\Users\用戶名\.ssh\known_hosts)。dd 刪除整行。:wq。# 刪除前示例
192.168.1.2 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAs7tE1nlC8YUMHkJUmSpFeJCc0ztFQiWGIKlyrnf4KVCz+Ece/yY59QXnVG7b0DWA/wyzlaGRdumWFexX4Y7VE3WunEeXVPMRjF0YZgG5qW6EDXNMEquZzI5k7Jg96VGq+5ZzhtsRhUqXH1aNrMYydRfMUFDXTh+a3jKcoQLx9IiifouUuh5JEelql9w9FRgmOgOqmm3CVbn33mblyHZa0UOa3GDpFGRxFjxyPVLuOD90rJIVc126CxIK3TmsFS0emO7qxpz4mrNG/1xpCqgKxNejBkrlUtxzLxGbwuod3HPX7OB28uk1RdGsXhcZtKsPph3a04i7Y5C5QZ1XDXFzDQ==
192.168.1.3 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsI5fLkoQayuhjMLXaE69VlxA7en/SmxXs+VDjgXLGLLTLdSOxki1cBDzuPm4FefmES4A3X3mfAB8L46rFnPJe45hca4U6uC...
ssh root@66.105.230.188
# 提示 Are you sure you want to continue connecting (yes/no/[fingerprint])? 輸入 yes
# Warning: Permanently added '66.105.230.188' (RSA) to the list of known hosts.
known_hosts 存儲「主機標識 → 公鑰指紋」映射,防禦中間人攻擊 (MITM)。ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@IP (僅測試環境使用)。安全提醒: 若非預期變更 (未重裝/未遷移),收到此警告**極大概率遭遇中間人劫持**,請立即通過帶外渠道 (控制台/VNC/服務商工單) 驗證服務器指紋,切勿盲目 `yes` 繼續。