Tips

SSH connection problem


You want to connect to your server over SSH but you get the following problem?

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
...

Explanation

As the message says, it’s a safeguard warning you that the server you want to connect to has changed and that there is a risk of a man-in-the-middle attack.
That is, someone could be pretending to be your server and capturing the data you send.
It’s just a precaution.

Solution

To know whether the server in question has changed, a file is saved on your computer the first time you connect. This file is a bit like the server’s ID, so if the server changes, its ID changes too, and since it’s different you get this message.

All you have to do is delete the “.ssh” folder located in “C:\Users\your_username”.
Make sure to replace “your_username” with your actual username.

A little extra

If you care about security and want to change the certificate of a single server rather than delete everything, just go to the “known_hosts” file in the “.ssh” folder and edit what you want by opening it with Notepad or Visual Studio Code, for example.
You can delete/edit the line corresponding to the server whose ID has changed.