How to solve on MacOS “REMOTE HOST IDENTIFICATION HAS CHANGED”

Once I transferred the IP address to another server and after connecting to it via SSH from MacOS I saw a warning and therefore failed to connect:

@@@@@@@@@@@@@@@@@@
@ 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 ECDSA key sent by the remote host is
SHA256:XXXXXXXXX.
Please contact your system administrator.
Add correct host key in /Users/ixnfo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/ixnfo/.ssh/known_hosts:9
ECDSA host key for [192.168.2.2]:22 has changed and you have requested strict checking.
Host key verification failed.

The problem arises due to the fact that earlier at this IP address I connected to one server and the key was saved in the file known_hosts, and now it is another server with a different key.

If you have changed this and in order to solve the problem, run “Terminal” and open the file known_hosts, for example in the text editor nano:

nano .ssh/known_hosts

After that, delete the line with the key for this IP address.
And the next time you connect to the server, the new key is already recorded.

In the nano editor, being on the line you want will delete it by pressing CTRL+K, then press Ctrl+X to exit and “y” or “n” to save or cancel changes.
You can also save changes with Ctrl+O.

If you have not made any changes on the server and you see this warning, then you probably are not connecting to your server.

Leave a comment

Leave a Reply

Discover more from IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading