2

I need to simulate the warning:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!  @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

I have two Linux machines and when I do ssh from Linux1 to Linux2, ssh accepted and reports no problem.

But because some of testing, I want to simulate the - Identification Has Changed error

So what I need to edit on the remote server in order to create the problem?

what I did until now is to change the knpwn_hosts on both machine but its not creating the problem.

I get this:

 key_read: uudecode AAAAB3NzaC1y3jrzG62xyHrb3qxc9eYpg1Cp1PrRElTFfYbEHsRfTZU21S8kO5/Tq+ED8=
 failed
 key_read: uudecode AAAAB3NzaC1y3jrzG62xyHrb3qxc9eYpg1Cp1PrRElTFfYbEHsRfTZU21S8kO5/Tq+ED8=
 failed
 The authenticity of host 'ste1 (10.106.164.111)' can't be established.
 RSA key fingerprint is 84:82:2b:80:ca:3f:57:c7:8c:14:44:dd:b9:70:e5:d8.
 Are you sure you want to continue connecting (yes/no)? 
  • Change the entry in known_hosts... – jasonwryan Nov 4 '14 at 7:43
  • already did it - It not cause this problem – maihabunash Nov 4 '14 at 7:44
4

Swap/change host entries in ~/.ssh/known_hosts so that an incorrect IP address is listed for your host:

From:

192.168.0.10 ecdsa-sha2-nistp256 AAAAE2...kFr3pqkY=
192.168.0.20 ecdsa-sha2-nistp256 AAAAE2...A82zdls0=

To:

192.168.0.20 ecdsa-sha2-nistp256 AAAAE2...kFr3pqkY=
192.168.0.10 ecdsa-sha2-nistp256 AAAAE2...A82zdls0=

(Note that the IP addresses has been swapped)

Will then give you:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is

You get this warning when the key offered by the client pair with the key on the server, but the IP address differs. The assumption then is that you're the subject of a man-in-the-middle attack and a warning is issued.

3

One way is to change the keys on the remote server so when they are verified against the entry in your known_hosts file it won't match and give you that message.

Regenerate your host keys on the remote server with something like:

ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa -b 521

Then restart the SSH server.

You could also edit the known_hosts file on the client to contain an entry for another server but with the hostname of the remote server you want to get the message with.

  • see the update in my question - this is the message that I still not get the message with WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! – maihabunash Nov 4 '14 at 7:59
  • Yet my second suggestion which apparently doesn't work is what was in the accepted answer. – Garry Harthill Nov 4 '14 at 18:21
0

Probably the easiest way is just to copy another host's key.

For example, if you have a known_hosts file with something like

192.168.1.1 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwCrkL8HEVk8VP3r...
192.168.1.2 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeL...

and you want 192.168.1.2 to show an error, just copy 192.168.1.1's host key, so known_hosts would now look like

192.168.1.1 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwCrkL8HEVk8VP3r...
192.168.1.2 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwCrkL8HEVk8VP3r...
0

What you need to do is to regenerate the host keys in the remote server (the server to which you are trying to SSH to) so that its ssh_host_key.pub will change and will give you the Identification Has Changed error. This URL has steps to regenerate the host keys in debian server. Please translate to your version of Linux and it will work for you.

0

What you can do is to regenerate the server keys (after backing up the previous ones if you need to revert back to them):

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key 

Edit: @jjlin answer is definitely less intrusive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.