ssh-copy-id 遇到ERROR: Host key verification failed.
由于在/home/user/.ssh/known_hosts中记录的目标机器信息与当前不符(多为重用了IP地址造成),执行Ssh-copy-id时有下面的报错:
[bmsc_ci@jenkins-slave2 ~]$ ssh-copy-id -i /home/user/.ssh/id_rsa.pub root@192.168.125.112
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the RSA key sent by the remote host is
ERROR: 39:b0:5f:e1:01:77:fe:5b:b9:ff:2d:2b:a0:fd:f5:3a.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
ERROR: Offending RSA key in /home/user/.ssh/known_hosts:185
ERROR: RSA host key for 192.168.125.112 has changed and you have requested strict checking.
ERROR: Host key verification failed.
解决方法:
ssh-copy-id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /home/user/.ssh/id_rsa.pub root@192.168.125.112
同样地,此情况时ssh, scp 也会报错,解决办法是:
ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.125.112
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r /var/tmp/performance/moo.dat root@192.168.125.110:/var/tmp/