ssh-keygen can remove entries from known_hosts
Sometimes host keys change and we have to remove their corresponding entries from .ssh/known_hosts
. Instead of doing that manually, you can use ssh-keygen
with the -R
option:
$ ssh-keygen -R foo.com
# Host foo.com found: line 1
# Host foo.com found: line 4
/Users/gh/.ssh/known_hosts updated.
Original contents retained as /Users/gh/.ssh/known_hosts.old