When trying to SSH to another machine and getting the following
message and the public key of the remote machine has changed since
your last login, you'll be presented with the following error;
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
..........
This is caused by the fact that SSH is by default configured to check
for the remote machine's host key every time a connection is to be
established.
You can fix the problem by whether disabling the key check, or have
the right key in your ~/.ssh/known_hosts file.
Disable key check
To do this temporarily when connecting to a remote server, add the
StrictHostKeyChecking no option when running your SSH command as in
the example below;
ssh -o 'StrictHostKeyChecking no' user@host
To make it permanent and system-wide, edit the SSH client
configuration file, and add the following line (if it doesn't already
exist)
StrictHostKeyChecking no
The file can normally be found at /etc/ssh/ssh_config
Update known-host file
~/.ssh/known_hosts is where the host keys are stored. A sample entry
of the file is as the following
192.168.0.111 ecdsa-sha2-nistp256
AAAAE2DjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBInXA+7gb/
gR0rOWlxzAvlt1SVEPamQBqRVbkDe7M4eZ3OC/yMXEA0QP8va62rGxvEx0quWf1FROQclYPc0NrT0=
example.com ecdsa-sha2-nistp256
AAAAE2VjZHNhLXNoaTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAACBBInXA+7gb/
gR0rOWlxzAvlt1SVEP1mQBqRVbkDe7M4eZ3OC/yMXEl0QP8va62rGxvEx0quWf1FROQclYPc0NrT0=
10.0.0.2 ssh-rsa
AAAAB3NzaC1yc2EAAAACAQABAAABAQCu9MUCkl0C7pXE//vtoRoxgVFGKOPWxvf1zA0HKYlHl5hR
/HL3TTZbmoqA/aet0VLAunetMOkQuSaLDCAJPQQ21DD5db6CMkjAtUkR/
xfGKiT8ZWBitBRE4cbBoPVhY9rjMtHlUFGy7pFYOSVau7rBxhsX9F9pIWDDuBEytjl3q5HAF+
qBOKrcdEcsMieCVhcEQRo2HkJ4r/8dR0Nxvtq05X3LAj8tFZJ34ClfA7iiALVRCHYxK8VyJHew1jxBJGbnZU/
vIndIcHjJO1TftfBOo7wDo1NeVD0UE7dYszu7mvY4tJKaPAgMGIAUScZ7c2BaLGk9gVLXkRzU+zQ6IpYf
You can use your favorite text editor to remove the offending line, or
you can also use the ssh-keygen program. The syntax for the ssh-keygen
program is as the following;
ssh-keygen -R hostname (for example: ssh-keygen -R 192.168.1.23 )