Dev Notes

How to Fix “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!” (Mac, Linux, Windows)

Remote Host Identification Changed: Fix the SSH warning safely on Mac, Linux, Windows

Quick answer

This SSH warning means the server’s host key no longer matches the one saved in your known_hosts file. It is usually harmless (the server was rebuilt, reinstalled, or the IP now points to a new machine), but it can also signal a man-in-the-middle attack. Once you have confirmed the change is expected, remove the old key with ssh-keygen -R hostname (or the IP), reconnect, verify the fingerprint and accept it.

Key takeaways

  • Don’t ignore the warning blindly. Confirm why the key changed first.
  • The fix is one command: ssh-keygen -R your-server, on Mac, Linux and Windows 10/11.
  • Remove the entry for both the hostname and the IP if you connect both ways.
  • Verify the new fingerprint against your cloud console or the server itself.
  • Never disable StrictHostKeyChecking globally to make the warning go away.

You try to connect to a server and SSH stops with a wall of @ symbols:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
...
Offending ED25519 key in /home/you/.ssh/known_hosts:12
Host key verification failed.

Here is what it means, how to decide whether it is safe, and how to fix it on every operating system.

What does “remote host identification has changed” mean?

The first time you connect to a server, SSH saves its public host key in ~/.ssh/known_hosts. On every later connection it checks that the server presents the same key. If the key is different, SSH refuses to connect, because it cannot tell whether you are talking to the real server or to someone intercepting the connection.

Why did the host key change?

Common, harmless reasonsReasons to be concerned
Server was rebuilt or the OS reinstalledYou connected over public Wi-Fi and nothing changed on the server
Elastic or static IP moved to a new instanceNobody on the team changed the server
Host keys were regenerated during hardeningThe warning appears for several unrelated servers at once
Hosting provider migrated the serverFingerprint doesn’t match what the provider console shows
Different server now uses that hostname (DNS change)

If you can’t explain the change, stop and check with whoever manages the server before going further.

How do I fix it on Mac and Linux?

ssh-keygen -R server.example.com
ssh-keygen -R 203.0.113.10
# For a custom port:
ssh-keygen -R "[server.example.com]:2222"

This removes the saved key and keeps a backup as known_hosts.old. Now connect again with ssh [email protected]. SSH shows the new fingerprint and asks whether to continue. Check it (next section), then type yes.

Alternatively, open ~/.ssh/known_hosts in an editor and delete the line number shown in the warning (“known_hosts:12” means line 12).

How do I fix it on Windows?

Windows 10 and 11 include OpenSSH. In PowerShell or Command Prompt run the same command:

ssh-keygen -R server.example.com

The file lives at C:\Users\YourName\.ssh\known_hosts if you prefer to edit it by hand. If you use PuTTY, it stores host keys in the registry and shows its own “host key does not match” dialog; once you have verified the change, choose “Accept” to replace the stored key.

Rather have experts handle this?

My team at NexGeno manages servers, cloud, security and WordPress for businesses in India and abroad.

Talk to my team WhatsApp me

How do I verify the new fingerprint is genuine?

Get the real fingerprint from a trusted channel and compare it with what SSH shows:

  • On the server itself (via your provider’s web console): ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
  • AWS EC2: Actions → Monitor and troubleshoot → Get system log, which prints the host key fingerprints on first boot.
  • Your team or provider if they rebuilt the server.

If the fingerprints match, accept the key. If they don’t, don’t connect, and investigate the network you are on.

Can I just turn off host key checking?

You can, with -o StrictHostKeyChecking=no, but don’t do it globally. It removes the protection this warning gives you. For automation that rebuilds servers often, a better pattern is to add the new key with ssh-keyscan from a trusted network as part of the build, or to use SSH certificates so clients trust a certificate authority instead of individual host keys.

Why do I see this in Git, VS Code or deployment tools?

Git over SSH, VS Code Remote-SSH, FileZilla SFTP and CI pipelines all use the same known_hosts check. Fix it the same way. For GitHub specifically, compare with the fingerprints GitHub publishes in its documentation; GitHub rotated its RSA host key in March 2023, which triggered this warning for many developers.

Frequently asked questions

Is “remote host identification has changed” dangerous?

Usually not. Most of the time the server was rebuilt or its IP moved. It can indicate a man-in-the-middle attack, so confirm the change and verify the new fingerprint before accepting it.

What command fixes the remote host identification error?

Run ssh-keygen -R followed by the hostname or IP address, then reconnect and accept the verified new key. The same command works on macOS, Linux and Windows 10/11.

Where is the known_hosts file?

On macOS and Linux it is ~/.ssh/known_hosts. On Windows it is C:\Users\YourName\.ssh\known_hosts. PuTTY stores host keys in the Windows registry instead.

Why does the warning keep coming back?

If the server is rebuilt often, or several servers share one IP or hostname behind a load balancer, the key will keep changing. Use stable host keys in your images, SSH certificates, or separate hostnames.

Tamir Khan: business growth and digital strategy consultant in Mumbai. Since 2011 he has built websites, SEO, Google Ads, cloud and automation systems for businesses in India, the UK, Canada, the USA and the UAE. Strategy comes from Tamir; delivery is by the NexGeno team. About Tamir · LinkedIn

Last updated: 25 November 2026

Related Posts

Quick Links

Newsletter

I am the Founder and Chief Technology Officer at NexGeno Technology Pvt Ltd. With 12+ years of experience, I specialize in digital strategy, business automation, AI integration, web development, and marketing.I've worked with startups, SMEs, and global clients, offering tailored strategies that deliver measurable results.

© 2025 Tamir Khan - All Rights Reserved | Managed by NexGeno