当尝试连接到 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 |