Networking ·

Resolving "Remote Host Identification has changed" error when using SSH

This is a tutorial on how to solve issues when connecting to an edge device using SSH.

Resolving "Remote Host Identification has changed" error when using SSH

SSH (Secure Shell) is a protocol used to securely connect to a remote client. However, sometimes you may encounter issues when trying to establish an SSH connection, particularly on a Windows system.

These issues often occur due to conflicts with previously stored public keys associated with the IP address you're trying to connect to. In this tutorial, we'll go over two possible solutions to these problems. For more information about public keys and secure communication, please check out our blog article about it.

The first and more secure solution is to manually remove the conflicting public key from your known hosts.

  1. Navigate to your SSH directory. By default, it should be located at C:\Users\<YourUsername>\.ssh.
  2. Open the known_hosts file. This file contains the public keys of all previously connected hosts.
  3. Search for any entries associated with the IP address you're having trouble with and delete them.
  4. Save and close the known_hosts file.

The next time you attempt to connect to the IP address, you'll be asked whether you trust the host. Simply respond with 'yes' to proceed.

Alternatively, you can choose to delete the entire known_hosts file. However, please note that this will result in SSH asking for your trust every time you connect to a previously known IP address.

Solution 2: Disable Strict Host Key Checking

The second solution involves disabling strict host key checking. This will prevent SSH from asking for your trust when connecting to a host. While this solution can be more convenient, it can also pose a security risk if you're connecting using a password instead of SSH keys. If someone manages to redirect the IP address to their machine, they could potentially gain access to your password and, subsequently, your edge device.

  1. Navigate to your SSH directory, located by default at C:\Users\YourUsername>\.ssh.
  2. Open the config file using a text editor. If this file does not exist, create a new one. Insert the following code at the top of the file:
Host * 
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
  1. Save and close the config file.

With these settings, SSH will no longer perform host key checking, and it won't store any keys in the known hosts file.

Conclusion

This tutorial has presented two different solutions to SSH connectivity issues on Windows, both of which involve manipulating the known hosts file or SSH configuration settings. Always remember to consider the security implications of your chosen solution.

Read next

Share, Engage, and Contribute!

Discover how you can share your ideas, contribute to our blog, and connect with us on other platforms.