4 ms·
One-liner to update your `known_hosts`, directly from github (if you have `jq`) ssh-keygen -R github.com && curl 'https://api.github.com/meta' | jq -r '"gith
by cprecioso 4y ago
One-liner to update your `known_hosts`, directly from github (if you have `jq`)
ssh-keygen -R github.com && curl 'https://api.github.com/meta' | jq -r '"github.com " + .ssh_keys[]' >> ~/.ssh/known_hosts
- masklinn 4y agoSeems unnecessarily complicated, you can just `ssh-keygen -R` then `ssh git@github.com`, it should ask if you want to add the new key to the known hosts. Also you should first check: 1. If you’re using GitHub’s rsa key at all 2. That you don’t have the other keys In which case nuking all the keys is completely unnecessary, just remove the RSA one.
- jwilk 4y ago> it should ask if you want to add the new key to the known hosts But how do you know it's the right key?
- masklinn 4y agoBy comparing the fingerprint to a trusted source, which the snippet above doesn't do. And if you trust that the https source will lead you to the correct github, you can trivially check the fingerprint against what github publishes.
- cprecioso 4y agoYou’d be pressed to find someone who doesn’t trust the https source. So… you’d do manually what the snippet does?