I was trying to scp files from one server to another server.
when I hit scp it scolded me that "Host key verification failed."
[appprd@host01 PRD]$ scp -pr xxlpr apptst@host02.domain.com:/u02/app/apptst/
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE host01 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 host01 is
80:f3:c5:26:16:d1:9a:23:8d:c9:00:44:84:75:1a:7f.
Please contact your system administrator.
Add correct host01 key in /u01/app/appprd/.ssh/known_hosts to get rid of this message.
Offending key in /u01/app/appprd/.ssh/known_hosts:5
RSA host01 key for host02.domain.com has changed and you have requested strict checking.
Host key verification failed.
lost connection
Cuase: The same Host was registered with different key in $HOME/.ssh/known_hosts file
Solution:
Temporary: mv /u01/app/appprd/.ssh/known_hosts /u01/app/appprd/.ssh/known_hosts_old. Once the job is done replace again.
Permanent(in fact correct): remove the host01 key entry from $HOME/.ssh/known_hosts.
When you try scp again it will prompt you to add the new key, say yes. The new key will be added in known_hosts file.
Now it will not give your the error.
[appprd@host01 PRD]$ mv /u01/app/appprd/.ssh/known_hosts /u01/app/appprd/.ssh/known_hosts_old
[appprd@host01 PRD]$ scp -pr xxlpr apptst@host02.domain.com:/u02/app/apptst/
The authenticity of Host 'host02.domain.com (192.168.1.102)' can't be established.
RSA key fingerprint is 80:f3:c5:26:16:d1:9a:23:8d:c9:00:44:84:75:1a:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'host02.domain.com,192.168.1.102' (RSA) to the list of known hosts.
apptst@host02.domain.com's password: