I have 2 virtual machines with the same IP,  of course i cloned them a couple of day's ago. One was crashed and tried to point the second one in the Virt-Manger and attemted to connect via ssh. But i got this error.


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
06:54:ee:96:e0:27:11:63:7c:5d:ca:08:0a:15:a4:86.
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:1
RSA host key for 192.168.85.111 has changed and you have requested strict checking.
Host key verification failed.

You know why did this happend, my machine added the prevous machine & it's RSA key in .ssh/known_hosts file. So this time when i was attempting to connect to the machine with same ip, my machine checks for the RSA key but the copy of the RSA in the remote mahine does't match hense suspects and gives the above error.

We can do it in 2 ways

  • ssh-keygen  command
  • Removing the old key for the respective ip/system  from .ssh/known_hosts file manually.

[root@manny ~]# ssh-keygen -R 192.168.85.111
[root@manny ~]#  /root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old

That's all old RSA has been deleted. Now try log in using ssh.

[root@manny ~]# ssh 192.168.85.111
The authenticity of host '192.168.85.10 (192.168.85.10)' can't be established.RSA key fingerprint is 06:54:ee:96:e0:27:11:63:7c:5d:ca:08:0a:15:a4:86.
Are you sure you want to continue connecting (yes/no)?

Simply enter yes and type correct password. New key will be added that's all.

Another way is delete the entry for the respective ip address/system and save the file. And try logging again.

[root@manny ~]# vim .ssh/known_hosts
12.62.125.22 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA8vmtXCZd6llvAU1t2h57Qvcoem5BzBNRLqNvnfgy+UzHJcdWvuWM9TbdJUWJGGA5q+XWxanTVE5epPTTF7TIuXMc6y6iIXgkiJsu8xp44pmlIwSrxAX1koC4OuiFe6z7bZEgnpaXkXVECWVrD/JEmXMJT/KbkamCvboVkk5tGZ5XBoafo0avL84dI6YVMQibWbBHhkoikdfeH/Z4R8Znwv0fPgowXxIqLbDvWxRoco5/AvxWUa5UOBhJZAMf2BuTc1xeq7TvJdyh7m59XNaYRws/4BHx98KaEPY7S2jKrZqr0EY3pE2vhGJBRsl2bRR/1+s01yZwODXX5xSAGIIrZw==
192.168.85.111 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA8IIsVBWARL8tJ0dz1ZiBw9gep90G/MD3EVF3Yrwm9/IEEC0eoZSTOM/bwJ7I5L008ClgkypOd5Ofj3C7pJmh+k5GD3I0Kuq9a0O5G1PIsyFyd/CyIBxXnutVlIYqlw2F4gvQXwTiUzRUonSa2r/++y2RtJvIHvzHVTlPkH7q9IqUqsykCn2g96BjZKFmQ07dp/EVl+Ey0cTipzfbAyNdSijurGLjrV6dCbjFD4PEsv9hT77QhefUf4MV58Hx5HWD0+n/puGwV03fu67aiOooRjK9vVu2wuhSNOznXclRdXH6YeE3oKfNHo0QfiZDxuAc1fnvXZ8fgm27o+r9weVYWw==
~    

Just delete the entry for 192.168.85.111 and save the file, next time you try to connect to that ip new RSA key will be added in this file and you will be allowed to login.