Thursday 9 February 2012

Doing an scp shows "RSA host key for server has changed and you have requested strict checking."

As I was trying to do an SCP command, I got the below Warning.

[root@ajai_test03 /]# scp -r RPM_Patches ajai_test01:/u03/FROM_ajai_test03_IMP
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
3a:9f:30:9b:da:80:f8:6f:12:a9:86:84:91:ae:0e:d7.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:5
RSA host key for ajai_test01 has changed and you have requested strict checking.
Host key verification failed.
lost connection


==================

This was because of a previous RSA key present in the file  -  /root/.ssh/known_hosts.

I had to remove the key of the server it was pointing at, after that I was able to connect again.

Below is the step to remove the RSA key.
-----------------------------------------------------
[root@ajai_test03 /]# ssh-keygen -R ajai_test01
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@ajai_test03 /]#
[root@ajai_test03 /]#
[root@ajai_test03 /]#

===========================================================

After this has  been done, I tried doing the scp transfer again, and I was  able to transfer the files accordingly.



[root@ajai_test03 /]#
[root@ajai_test03 /]#
[root@ajai_test03 /]#

[root@ajai_test03 /]#
[root@ajai_test03 /]#
[root@ajai_test03 /]# scp -r RPM_Patches ajai_test01:/u03/FROM_ajai_test03_IMP
The authenticity of host 'ajai_test01 (192.18.5.54)' can't be established.
RSA key fingerprint is 3a:9f:30:9b:da:80:f8:6f:12:a9:86:84:91:ae:0e:d7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ajai_test01,192.18.5.54' (RSA) to the list of known hosts.
root@ajai_test01's password:
sun-javadb-core-10.5.3-0.2.i386.rpm                                                                                         100% 3886KB   3.8MB/s   00:00
numactl-devel-0.9.8-11.el5.x86_64.rpm                                                                                       100%   17KB  16.7KB/s   00:00
unixODBC-2.2.11-7.1.i386.rpm                                                                                                100%  832KB 831.5KB/s   00:00
unixODBC-devel-2.2.11-7.1.x86_64.rpm                                                                                        100%  793KB 793.3KB/s   00:00
glibc-headers-2.5-49.x86_64.rpm                                                                                             100%  592KB 591.6KB/s   00:00
libaio-devel-0.3.106-5.x86_64.rpm                                                                                           100%   11KB  11.4KB/s   00:00
gdbm-1.8.0-26.2.1.i386.rpm                                                                                                  100%   27KB  27.1KB/s   00:00
gcc-4.1.2-48.el5.x86_64.rpm                                                                                                 100% 5393KB   5.3MB/s   00:01
unixODBC-2.2.11-7.1.x86_64.rpm                                                                                              100%  837KB 836.7KB/s   00:00
p6078836_101330_LINUX.zip                                                     


==============