Fix "Remote Host Identification Has Changed" in SSH

You try to reconnect to a server you have used for months, and the client stops you. It says the host key, or the fingerprint, is not the one it remembers.

This is not a broken setting. The client is telling you: the machine at this address is presenting a different identity than last time. Sometimes that is expected. Sometimes it is a warning you should take seriously.

This guide is about reading that warning, comparing fingerprints, and only then choosing to accept or refuse the new key. It is not a guide to bypassing host-key checks.

Why SSH remembers a host key at all

The first time you connect to a server, the SSH client stores that server’s public host key (usually as a short fingerprint). On every later connection it compares what the server sends with what it stored.

If the two do not match, a safe client refuses to continue until you decide. That check is what stops you from typing a password into a different machine that happens to be sitting on the same hostname or IP.

OpenSSH prints a “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED” message and, in standard checking modes, will not let the session continue. A graphical client should do the same, and should show you both fingerprints.

When a change is expected

A new host key is normal after things that actually replace the server’s SSH identity:

If none of those happened, treat the warning as unexpected.

When you should not accept the new key

Do not confirm a changed key if:

In those cases, cancel the connection. On another computer or through your provider’s console, check whether the server is the one you think it is, and whether DNS for that hostname still points where it should. Only after you have a fingerprint from a trusted source should you consider accepting the new key.

Do not turn off host-key checking to “just get in.” That removes the warning instead of answering it.

How to verify the new fingerprint

You need the new fingerprint from a place that is not the same SSH session that just warned you. Options that are usually safe:

  1. Your cloud or hosting panel, if it displays the instance’s SSH host fingerprint after a rebuild.
  2. A colleague who already accepted the new key after the planned rebuild, and who can read the fingerprint out-of-band (chat, ticket, in person).
  3. A console session you already have on the machine (serial, cloud “open console”, or a hypervisor window), where you can read the host key from the server itself.

Compare that value with the new fingerprint your SSH client is showing. Compare the whole string, not just the first few characters. If they do not match, refuse.

How you print a fingerprint on the server depends on the OS and SSH build, so follow your own admin runbook. If you use OpenSSH on your own PC, remove the stale line from known_hosts only after you have verified the new key, not instead of verifying it. The next section shows the exact command.

The exact warning, and how to update known_hosts

OpenSSH prints this message when the key no longer matches what it stored:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

Searches for “ssh host identification has changed”, “ssh update known_hosts” and “ssh-keygen -R” are about this same warning. Treat it as a prompt to verify the new fingerprint first, then remove only the stale line. Do not skip the check, and do not turn host-key checking off.

  1. Compare the new fingerprint with a source you already trust (your hosting panel, a colleague out-of-band, or a console session on the machine), as described above. If it does not match, stop. Do not delete the old key and do not connect.
  2. Only after the new fingerprint checks out, remove the old host key with OpenSSH:
ssh-keygen -R <host>

If you connect on a non-default port, include the brackets and the port, the same way OpenSSH stores it:

ssh-keygen -R [<host>]:<port>

That command edits your known_hosts file and deletes the stale line for that host (including hashed entries). The usual paths are:

The next connection should then ask you to accept the verified new key, and OpenSSH will write the new line. A graphical client such as easy-ssh keeps its own store; updating known_hosts does not always update the app, and the other way around.

What a careful Windows client should show you

A good graphical client will remember each server’s fingerprint, stop if it changes, show the old and the new fingerprints in the same dialog, require an explicit confirm before connecting, and not have a hidden “always accept” default.

easy-ssh, a free open-source SSH client for Windows, does this in version 1.2.1: every server’s fingerprint is stored, and a changed key shows the old and new values and waits. The project’s README describes the order as: click the saved server, check the stored hosts, and only then authenticate. That is the behaviour you want, whether you use easy-ssh, OpenSSH, or another client.

If a client offers “accept and don’t ask again” without showing both fingerprints, do not use that option on a warning you have not verified.

A simple decision table

After you accept a genuine new key

What this does not cover

This is not a walkthrough for attacking a connection, disabling verification, or writing scripts that auto-accept keys. If you administer servers, keep host keys stable across rebuilds when you can, so users are not trained to click through warnings.

Further reading