當嘗試連接到 SSH 時, 有時會因為 Server 端的變動出現 “Host key verification failed” 錯誤。
|
1 2 3 4 5 6 7 8 9 10 11 12 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 Please contact your system administrator. Add correct host key in /home/phpini/.ssh/known_hosts to get rid of this message. Offending key in /home/phpini/.ssh/known_hosts:10 RSA host key for IP_ADDRESS has changed and you have requested strict checking. Host key verification failed. |
“Host key verification failed” 的意思是自從上次連接到 SSH 後, Server 的 host key 變更了,系統基於安全理由拒絕連線。
解決方法分別有以下幾種: (下面假設帳號是 phpini)
1. 將 known_hosts 刪除:
$ rm -f /home/phpini/.ssh/known_hosts
2. 如果不想刪除整個 known_hosts 檔案, 可以只刪除 known_hosts 檔案內 Server 相應的行數。開啟 /home/phpini/.ssh/known_hosts 檔案, 找到 Server 的 IP 地址的一行, 直接刪除後儲存離開即可。
3. 這個方法不建議, 因為會對整個系統生效, 只在此分享一下。
開啟 SSH 的設定檔 /etc/ssh/ssh_config, 分別將 StrictHostKeyChecking 設定成 “no”; 及 UserKnownHostsFile 設定成 “/dev/null”, 即改成這樣:
|
1 2 |
StrictHostKeyChecking no UserKnownHostsFile /dev/null |