Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!"

SSH sees a different key for a server it already knows. Learn why, how to check it is safe, and how to remove the old key.

VPS and Cloud Servers2 min read4 steps9 screenshots

What it means

When you connect with SSH, your computer saves the key of the server in ~/.ssh/known_hosts. If the key changes later, SSH stops with:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
The remote host identification has changed warning

Common causes

The warning message in detail
  1. The server was reinstalled or upgraded. A new SSH host key was created.
  2. The IP address now belongs to another server. This happens often with cloud servers.
  3. The admin changed the key on purpose.
  4. A man-in-the-middle attack. This is rare but serious.
Warning: Before you remove the key, make sure the change is expected. If you did not reinstall the server, ask your provider or compare the fingerprint with the one in your control panel.

Find the old entry:

ssh-keygen -F hostname_or_ip
Finding the old host key

Remove it:

ssh-keygen -R hostname_or_ip

For example:

ssh-keygen -R 192.168.100.4
Removing the old host key

Connect again. SSH asks you to accept the new key. Check the fingerprint, then type yes:

ssh user@hostname_or_ip
Connecting and accepting the new key

Method 2: Edit known_hosts by hand

The warning names the file and the line number. Open the file and delete that line:

nano ~/.ssh/known_hosts
Editing the known_hosts file

Save the file and connect again:

ssh user@hostname_or_ip
Connecting again

Only for a throw-away test. This switches off a security check:

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@hostname_or_ip
Connecting without host key checking

Method 4: Add the new key yourself (for controlled setups)

ssh-keyscan -H hostname_or_ip >> ~/.ssh/known_hosts

For example:

ssh-keyscan -H 192.168.100.4 >> ~/.ssh/known_hosts
Adding the key with ssh-keyscan

Compare the fingerprint with a trusted source before you rely on it.

Avoid the problem

  • Use DNS SSHFP records so that clients can verify keys.
  • Tell users before you change SSH keys.
  • Keep the host keys when you rebuild a server (copy /etc/ssh/ssh_host_*).
  • Do not turn off StrictHostKeyChecking in daily use.
  • Use configuration tools such as Ansible to spread host keys safely.

Quick recap

  • A changed key may be harmless, or an attack. Check first.
  • Remove the old key with ssh-keygen -R host.
  • Connect again and check the new fingerprint.