Skip to content

Instantly share code, notes, and snippets.

@kany
Created September 13, 2012 15:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kany/3714996 to your computer and use it in GitHub Desktop.
Save kany/3714996 to your computer and use it in GitHub Desktop.
Git Repo changes ssh fingerprint - how to update your known_hosts file
1) Open known_hosts file and look for the invalid host
nano ~/.ssh/known_hosts
2) Remove the line that has the invalid host. Should be the same host in your .git/config of your repo
ssh-keygen -R [dev.blahblah.com]:1234
3) Pull from repo
git pull
4) You should see something similar to this. Answer 'yes' when asked.
The authenticity of host '[dev.blahblah.com]:1234 ([1.2.3.4]:1234)' can't be established.
RSA key fingerprint is 4d:70:fc:34:43:3d:93:9e:42:29:cz:94:48:51:cz:18.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[dev.blahblah.com]:1.2.3.4,[9.8.7.6]:1234' (RSA) to the list of known hosts.
@xero
Copy link

xero commented Mar 24, 2023

if you know the name of the domain host in file, you can just do this in a single command:
ssh-keygen -f ~/.ssh/known_hosts -R "github.com"

replace github.com whatever host you want to remove

@kany
Copy link
Author

kany commented Mar 24, 2023

Awesome! Thanks, @xero 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment