ssh connection error: Warning: Remote host identification has changed


The “Warning: Remote host identification has changed” error typically occurs when the SSH host key of the server you are trying to connect to has changed. This could happen for various reasons, such as the server being reinstalled, the SSH keys being regenerated or the server is connecting to internet via different port.


'Warning: Remote host identification has changed'.

I am on Windows 11 and use "Git Bash" as my terminal here.

Warning: Remote host identification has changed


And same warning while trying to connect to remote server via "Termux Terminal" on Android 12:
Warning: Remote host identification has changed

Fixing the error “Warning: Remote host identification has changed” in Windows 11


Warning gives a hint that points to the cause of problem:

> "Add correct host key in /c/users/USER/.ssh/known-hosts to get rid of this message."

Solution:
In ssh directory, you'll find a file named known_hosts. This file contains the saved host keys for the servers you have connected to. Open the known_hosts file in a text editor (you can use nano, vim, or any text editor you prefer) and delete the line corresponding to the host that is causing the issue.

  1. cd in “.ssh” folder which is located in your home folder.

You can use this command both in PowerShell and Git Bash:

cd && cd .ssh

  1. Open the known_hosts file in text editor.

Using Git Bash to edit known_hosts file:
Now open the file named "known-hosts" in your text editor. "vi" text editor is bundeled with Git Bash:
vi known_hosts

using powershell: First open the folder in windows explorer and then use any text editor to edit the file and save it.
explorer .

Now you will see a list of ip addresses and the ssh key for connecting to that ip address. In known_hosts file, there may be three different ssh algorithms for the same ip address like these three lines below. All the lines with same ip address should be deleted then save the file and exit.

192.152.02.02 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII6Ed9tqK1zclk4HqG5c4SaZJZ4Ow2FvD08m4r7/p4a4

192.152.02.02 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQEA4e/Bsr41O/B08v6fW48AuvMEy44M4P6/p+Y/V/ic87/KYL/Sw37OzQ44P/2G/A3g/w/D8f/H/27/6/X/87/4/2/+8/

192.152.02.02 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGqG5c4SaZJZ4Ow2FvD08m4r7/p4a4AAAAC3NzaC1lZDI1NTE5AAAAIB8O3v7q7OuJ+Py5O/6e6u/ve/v/ve/v/ve/v/ve/v/ve/v/ve/v/ve/v/ve/
  1. try again to connect to your remote server via ssh
  2. you will get a message which asking “Are you sure you want to continue connecting (yes/no/[fingerprint])? and answere “yes”.

How to solve it in Termux Android?


it is the samme process as in Git Bash.
cd && cd .ssh

vi known_hosts

remote host added to "known-hosts" file and connects successfully to remote server

And you are done. In my case I was trying to connect to my debian server which is a sbc “Orange Pi Zero 3”.

Warning: Remote host identification has changed


Tags: