If you have used SSH terminial logged in to the server, afterward you have reinstalled the OS, when you tried to login again you might got the following errors.

 

Error Message:

 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@    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:Mwn5EKR9A4+XXXXXXXXXXXXX

Please contact your system administrator.

Add correct host key in /Users/username/.ssh/known_hosts to get rid of this message.

Offending ECDSA key in /Users/username/.ssh/known_hosts:41

ECDSA host key for IP address has changed and you have requested strict checking.

Host key verification failed.

 

Resolution: 

If you are trying to connect to a remote server using SSH and encounter the "Host key verification failed" or the "Remote host identification has changed" warning, it indicates that your SSH client cannot verify the authenticity of the host you are connecting to.

 

Although it may look like a severe issue due to the nature of the warning, one of the most common reasons is not related to an attack: this usually happens whenever you have changed the OS on your VPS, if you reinstalled the OS or changed the root user password.

 

To fix it, follow these steps:

 

Step 1 - Remove the Entry From the known_hosts File

When you first connected to your VPS via SSH, a host key was added to the known_hosts file on your local device. Now, after changing or reinstalling your OS, this entry is outdated and needs to be removed. You can do so by entering the following command on the Terminal:

 

ssh-keygen -R [vps-ip]

 

Make sure to replace [vps-ip] with the IP of your VPS. This will create a backup copy of the known_hosts file and delete the host key entry associated with your VPS IP.

 

Step 2 - Connect to the Server

Now that the old entry is removed try connecting to your VPS again using SSH. This time,

you should be able to verify the host key and connect without issues.

 

If you are still unable to connect after following the steps above, you can try the following:

  • Verify that you are connecting to the correct IP address (or hostname)

  • Ensure that your firewall is not blocking the connection

  • Restart your local device or the VPS to reset the network settings

Cette réponse était-elle pertinente? 0 Utilisateurs l'ont trouvée utile (0 Votes)