↑ ↓ select, Enter open, Esc close

Remove an outdated host from known_hosts

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
ssh-keygen -R server.example.com

Removes all entries for a host from ~/.ssh/known_hosts, even if the file contains hashed hostnames. Useful when a server has been reinstalled and SSH therefore refuses to connect with a warning. A backup of the old file is saved as known_hosts.old.

Note: Only run this if the key change can be explained. An unexpected change may indicate a man-in-the-middle attack. For a non-standard port, the syntax is [host]:2222.

Also searched as

  • remote host identification has changed fix
  • remove host from known_hosts
  • ssh-keygen -R host

Related one-liners

All in SSH

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.