2

As we all know, when we try to login to remote Linux machine we do ssh $remote_machine and enter password.

In case the remote machine has been reinstalled from scratch then we should get the message:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

For some testing we want to simulate this scenario without reinstalling the remote machine, in order to get the error message

What do I need to configure on remote machine in order to get this message, without reinstalling the machine? (just for testing)

6

The ssh client checks the host key of the remote server, and complains if it's changed from what the client has previously saved. On the server (remote host), those host keys are usually stored in:

/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_host_rsa_key

You may edit those to trigger this warning. Most of the time, the ECDSA key is used. So editing ssh_host_ecdsa_key on the server should be sufficient to trigger the warning.

An alternative would be to edit the known_hosts file on the client, but modern versions of SSH only save a hash of the remote host name, so finding the correct line to modify will need some work.

  • just add that ssh_host_ecdsa_key should be update on the remote machine – yael Dec 21 '17 at 14:55
  • 1
    I took the liberty of elaborating this answer a bit. But it comes to mind that it might not be possible to modify the keys arbitrarily: public key algorithms have keys based on certain mathematical properties, and the key files might have checksums or such, too. But I don't know for sure. – ilkkachu Dec 21 '17 at 15:04
  • Technically, the warning for unknown hosts is different from that for hosts with changed key - the former lets you accept the fingerprint, the latter just tells you to fix known_hosts if you're sure. – Ulrich Schwarz Dec 21 '17 at 15:53

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.