对于家里以及公司内网的服务器,可能内网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
3f:1b:f4:bd:c5:aa:c1:1f:bf:4e:2e:cf:53:fa:d8:59.
Please contact your system administrator.

在客户端添加ssh配置,将相应主机的秘钥验证关闭即可。

cat <<EOF>>~/.ssh/config
Host 192.168.*.*
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null
  LogLevel QUIET
EOF

参考文章