This guide explains why you might see the SSH warning “REMOTE HOST IDENTIFICATION HAS CHANGED!” and how to safely fix it on macOS, Windows (using PuTTY or WSL), and Linux systems.

What This Warning Means

When you connect to a server via SSH, your system stores the server’s fingerprint (host key) in a file called known_hosts.

If the server’s fingerprint changes — for example, after a reinstallation, migration, or IP change — SSH detects a mismatch and shows this message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.

This is a security feature designed to prevent attackers from impersonating your server.

However, it often appears after legitimate server updates or migrations.

How to fix this?

Option 1 — Using Command Line (Mac & Linux)

  1. Open Terminal.
  2. Run the following command (replace your.server.com with your hostname or IP):

Use ssh-keygen to delete the invalid key

ssh-keygen -R "your.server.com"

This removes the outdated key from your ~/.ssh/known_hosts file.

Now reconnect to your server:

ssh username@your.server.com

You’ll be prompted to confirm the new fingerprint — type yes to continue.

Option 2 — On macOS (Graphical Method)

  1. If you use an app like Terminal, iTerm2, or VS Code Terminal, follow the same command steps as above.
  2. However, if you want to manually remove the old key:
  • Go to Finder → Go → Home Folder.
  • Open the hidden folder .ssh (press Cmd + Shift + . to show hidden files).
  • Open known_hosts using TextEdit or VS Code.
  • Search for your server’s hostname or IP and delete the corresponding line.
  • Save and close the file, then reconnect via SSH.

Option 3 — On Windows

If you use PuTTY:

  1. Open PuTTY.
  2. Go to Registry Editor → press Win + R, type regedit, and navigate to:
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys

Find and delete the entry corresponding to your server (starts with rsa2@22: followed by the hostname or IP).

Reconnect to the server in PuTTY; it will prompt you to accept the new key.

Ha estat útil la resposta? 0 Els usuaris han Trobat Això Útil (0 Vots)