2

We want to cause the status from a remote Linux machine to return

"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r",
"@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r", 

when we ssh to it, so we changed the one of the characters of the public key in the local /root/.ssh/known_hosts file ( beta machine ) in order to force this error to occur.

But this did not happen.

When we ssh to the remote machine from beta machine as

ssh alpha1

we gained access to the remote machine, but did not get the error:

"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r",
"@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r", 

How do we simulate this scenario and force this error to occur?

Michael Hampton
  • 252,907
shalom
  • 521

2 Answers2

2

Keep the first token (the IP address and port) and replace the rest with that from some other hosts's fingerprint in the same file.

Just tested it and it does indeed get me the error you're looking for.

1

Note, I haven't tested this, but it should work.

To trigger the warning (WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!) you could change priv/pub key pair server side as well, that has the added benefit you only need to do configuration change on a single host, and the change will apply to all connecting clients, whereas if you only make config edits clientside for known hosts (/home/user/.ssh/known_hosts), you need to do it on every client you want to display the warning on.

On the server in /etc/ssh/sshd_config you find an entry like

HostKey /etc/ssh/ssh_host_ed25519_key

Generate a new keypair on the server to replace the old:

sudo ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519

The key is most likely loaded fresh on the server for every client connecting, if not, restart the sshd.

See sshd_config documentation about HostKey

Quote:

Specifies a file containing a private host key used by SSH. It is possible to have multiple host key files. The default is /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key, /etc/ssh/ssh_host_ed25519_key and /etc/ssh/ssh_host_rsa_key for SSH protocol version 2.