另外一台服务器新装了系统,结果通过原有的服务器进行ssh跳转的时候报错,后来得出原因是因为ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,避免你受到DNS Hijack之类的攻击。
知道原因后便开始着手解决。
报错信息如下:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 23:00:20:83:de:02:95:f1:e3:34:be:57:3f:cf:2c:e7. Please contact your system administrator. Add correct host key in /home/adm/.ssh/known_hosts to get rid of this message. Offending key in /home/adm/.ssh/known_hosts:8 RSA host key for localhost has changed and you have requested strict checking. Host key verification failed.
如果是偶尔出现,可用此方法即可:
ssh-keygen -R 目标IP
如果是纯内网下经常碰到,可以这样:
vi /etc/ssh/ssh_config
修改里面的值:
StrictHostKeyChecking = no
至此解决。