Last active
April 5, 2019 10:06
-
-
Save nemzes/8d2fb1c99e07232ee82853cca9df1fe9 to your computer and use it in GitHub Desktop.
Trust GitHub public ket into .ssh/known_hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Adds the SSH public key for GitHub to the file defined in the KNOWN_HOSTS varible (below), | |
| # provided that the key matches the publicy published key fingerprint from GitHub. | |
| # Fingerprint can be fetched from https://help.github.com/articles/github-s-ssh-key-fingerprints/ | |
| # This should only ever change if GitHub's private keys are compromised and the keys are recreated. | |
| SHA256_RSA_FINGERPRINT="SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8" | |
| KNOWN_HOSTS=~/.ssh/known_hosts | |
| ssh-keyscan github.com 2>/dev/null | tee keyscan.txt | cut -f 2,3 -d ' ' | ssh-keygen -lf - | cut -f 2 -d ' ' | grep -q "$SHA256_RSA_FINGERPRINT" && cat keyscan.txt >> $KNOWN_HOSTS && rm keyscan.txt || (echo FAIL && exit 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment