Remote Host Identification Has Changed!
My biggest pain, mainly due to my constant server re-installs! Not so much because of the slightly scary message that you’re approached with when trying to SSH to one of your servers or devices (such as a Raspberry Pi!) but in all honesty its a really easy fix. You may have seen the “Remote Host Identification Has Changed!” message before, it looks similar if not identical to the image below except that the IP address will obviously the IP of the server you’re trying to connect to.
The main reason this happens is because you’ve either re-installed the operating system and your computer no longer recognises the server as one that was previously trusted.
To fix it, simply type the following:
ssh-keygen -R IPADDRESS
Obviously, where IPADDRESS is written will be the IP Address of the server or device you’re trying to connect to, in my case this is 192.168.0.14. You should get a response from the Mac Terminal similar to following message;
# Host 192.168.0.14 found: line 12
Original contents retained as /Users/Matthew/.ssh/known_hosts.old
Once this has been completed you will now be able to re-connect to the server and save it’s new SHA256 security key. If you do get this message and you haven’t re-installed your operating system it might be worth taking a look, as it could be possible that someone has gained access to your device and has attempted to change some of your precious files!
Incase of someone gaining access to your server/device it is always important to make sure you keep a backup as some other people aren’t as good-willingly intended as you are, some people out there have a malicious intent and just unfortunately want to see the world burn. Hopefully this isn’t the case and I hope it never is but it’s always better to be safe than sorry.
Best of luck, if you get stuck don’t hesitate to post a comment below and I’ll do my best to help you! More information on SSH Authentication Keys is available at: DigitalOcean – SSH Authentication Keys.