A warning that a server’s host identification has changed is not a routine login failure. SSH is telling you that the key presented by the server differs from the key saved for that destination. A rebuild or planned host-key rotation can explain the change, but an unexpected change can also mean you reached the wrong machine or someone is intercepting the connection.

The safe fix is to verify the replacement key through a trusted channel, then update only the matching known_hosts entry. Don’t disable strict host-key checking or accept a new key just to make the warning go away.

1. Stop and confirm the change

Don’t enter a password, passphrase, or other sensitive information after the warning. First, check whether a rebuild, key rotation, hostname change, or infrastructure migration was planned. If not, ask the server administrator or hosting provider to investigate before proceeding.

Confirm you are checking the same destination SSH uses. A DNS change, a different IP address, an SSH alias, or a nonstandard port can affect which host key entry applies. To inspect the effective settings for a connection, run:

ssh -G server.example.com | grep -E '^(hostname|port|user|proxyjump) ' 

ssh -G prints the effective client configuration without connecting. If you use an alias, inspect that alias rather than guessing what it resolves to. For name-resolution issues, see how to trace an SSH hostname before changing settings. A maintainable SSH config with aliases, ports, and jump-host settings can also make the destination clearer.

2. Verify the replacement fingerprint independently

Ask an administrator to obtain the fingerprint on the server, or use an authenticated provider console or other trusted management channel. For example, an administrator with shell access can run:

sudo ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub 

The output includes a key type, fingerprint, and usually a comment. Compare the fingerprint—not just the key type or comment—with the fingerprint shown in your SSH warning. Confirm that both refer to the intended server and the same key algorithm. If the server uses a different host-key algorithm, have the administrator provide that key’s fingerprint too.

The verification channel matters. Don’t use an unverified message sent over the same potentially compromised connection as your only confirmation. A fingerprint copied from the server using ssh-keyscan is useful for collecting a presented key, but it does not independently prove that the key belongs to the intended server. It cannot replace verification through a trusted channel.

If the administrator cannot confirm the fingerprint, stop. Keep the warning in place and investigate DNS, routing, the server’s identity, or a possible security incident.

3. Find the entry SSH is warning about

For the default port, inspect the entry using the hostname or address in the warning:

ssh-keygen -F server.example.com 

For a nonstandard port, OpenSSH stores the destination in bracketed form, with the port included:

ssh-keygen -F '[server.example.com]:2222' 

The same form applies when removing an entry. If you connect by IP address, alias, or a different hostname than expected, check the exact destination shown in the warning and the effective HostName from ssh -G. A hashed known_hosts file may hide hostnames when viewed in a text editor; ssh-keygen -F can still search for a specified host in it.

If a jump host is involved, the destination server and the jump host are separate SSH peers with separate host keys. Verify the key that triggered the warning; don’t remove or replace the jump host’s entry unless its key independently changed and was verified. For context on the two-hop connection, see using OpenSSH ProxyJump to reach private servers.

4. Remove only the verified stale entry

Once the replacement fingerprint is confirmed, remove the old entry for that destination. For a nonstandard port:

ssh-keygen -R '[server.example.com]:2222' 

For the default port, omit the port notation:

ssh-keygen -R server.example.com 

ssh-keygen -R edits the applicable known-hosts file and can remove matching entries even when hostnames are hashed. It may also create a backup of the original file. Avoid deleting the entire known_hosts file: that would discard trust records for unrelated servers and make their next connections harder to verify.

If the warning names a different hostname or IP than you expected, don’t remove entries for every possible name as a shortcut. Work out which destination SSH actually uses, verify its fingerprint, and remove only the corresponding stale record.

5. Reconnect and check the key

Reconnect using the same host and port. SSH should ask whether you want to trust the newly presented key because no matching saved entry remains:

ssh -p 2222 user@server.example.com 

Compare the displayed fingerprint with the one you verified independently. Accept the key only if they match. If they differ, cancel the connection and investigate; don’t accept it and hope to check later. After acceptance, SSH saves the key so it can detect a future change.

Avoid shortcuts that weaken the check

Don’t use StrictHostKeyChecking=no, delete your whole host-key database, or accept an unverified key to suppress the warning. Those approaches remove the check that helps SSH detect an unexpected server identity. A legitimate rebuild is a reason to update a verified key—not to stop checking keys.

I'm building ShadeTerm — an SSH client that organizes terminals, SFTP, code editing, and server tools into workspaces.