At some point during the installation of my Allsky system, I decided to start again for various reasons. To do this, I removed the micro SD card, loaded a new image and put the micro SD card back into the Raspberry Pi 5. During the next boot, an error message appeared with the information “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!”. Seems dramatic at first, but is quickly explained and easily fixed!
The error message looks something like this (of course with your data, e.g. your user name instead of pi and the name of your Raspberry instead of raspberry.local:
[user@hostname ~]$ ssh pi@raspberry.local @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 RSA key sent by the remote host is xx:xx:xx. Please contact your system administrator. Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message. Offending RSA key in /var/lib/sss/pubconf/known_hosts:4 RSA host key for user has changed and you have requested strict checking. Host key verification failed.
What does the message mean?
First of all: Strictly speaking, this is not an error message but actually a warning: The “known_hosts” file contains a list of SSH remote hosts that are known to the PC or Mac you are using to connect to the Raspberry. It serves as a reference file in the authentication process and helps to verify the identity of servers – or in this case the raspberry – that you are connecting to. When you connect to a server for the first time, you are usually asked to confirm the connection. If you agree, the server’s fingerprint is saved in your *known_hosts* file.
If the fingerprint later no longer matches the entry in the file, this may indicate a security incident – someone may be trying to gain unauthorized access. However, there are also harmless reasons for discrepancies, for example if the Raspberry has been reinstalled – as in my case. So in my case, the main thing was to rectify the error.
Fixing errors on the Mac:
Start the terminal program and remove the SSH key with the following command:
ssh-keygen -R [hostname]
Replace [hostname] with the IP address or the name of the server – e.g. raspberry.local
Then re-establish the SSH connection and confirm the new fingerprint of the server with “y”. This should be possible without an error message.
Alternatively, you can edit the known_hosts file directly:
Open the file with a text editor such as nano:
nano ~/.ssh/known_hosts
Remove the relevant entry, save the changes and then try to re-establish the connection.
Fixing errors on a Windows PC:
On Windows, fixing the error depends on the SSH client you are using.
If you are using OpenSSH:
Navigate to your user directory: Open File Explorer with the command %USERPROFILE%, go to the .ssh folder and open the known_hosts file with a text editor like Notepad.
Delete the incorrect entry: Find and delete the entry that is causing the error, save the file and reconnect.
If you are using PuTTY:
Start the registry editor by first pressing Windows+R and then typing “regedit” (without quotes) and confirming with the Enter key.
Then navigate to the following “folder” in the registry:
HKEY_CURRENT_USER/Software/SimonTatham/PuTTY/SshHostKeys/
Remove the problematic SSH key from the registry and confirm the deletion.
These steps will remove the old host identification so that you can then securely establish the connection with the new fingerprint. If it still doesn’t work, the old Windows rule sometimes helps: A new boot is always good!