Locate or Generate Your RSA Key
Most users store their keys in ~/.ssh. If you already ran ssh-keygen, the private key will be id_rsa and the public key id_rsa.pub. If you need to generate a new key, run ssh-keygen -t rsa -b 4096 -C "your_email@example.com" and accept the default location.
Compute the Fingerprint with OpenSSH
OpenSSH provides a direct way to view the fingerprint. Use the following command to read the public key and display its SHA‑256 fingerprint:
ssh-keygen -lf ~/.ssh/id_rsa.pub
Verify the Fingerprint on GitHub
Log into GitHub, go to Settings → SSH and GPG keys, and click the key you want to audit. The displayed fingerprint should match the one produced by ssh-keygen. If they differ, the key file may be corrupted or a different key is being used.
Common Pitfalls and Tips
- Ensure you are using the public key (.pub) file, not the private key. - The -lf flag shows the fingerprint in the default SHA‑256 format; use -E md5 for older MD5 fingerprints if required by legacy systems. - If you have multiple keys, specify the exact path to avoid confusion.
Automate the Check in Scripts
For CI pipelines or regular audits, embed the command in a shell script and compare the output against a stored value. Example:
key_path="~/.ssh/id_rsa.pub"
expected="SHA256:abc123..."
actual=$(ssh-keygen -lf $key_path | awk '{print $2}')
[ "$actual" = "$expected" ] && echo "Fingerprint matches" || echo "Mismatch detected"
Takeaway: The OpenSSH ssh-keygen -lf command gives you the RSA fingerprint you need for GitHub audits.
People also ask
How do I view the fingerprint of a private key?
Run ssh-keygen -lf path/to/private_key -E sha256 to compute the fingerprint from the private key.
Why does my fingerprint show as MD5 instead of SHA‑256?
Older OpenSSH versions default to MD5. Use -E sha256 to force SHA‑256 output.
Can I get the fingerprint for an SSH key stored on GitHub?
Yes, download the key file from GitHub or use the GitHub API to retrieve the key, then run ssh-keygen -lf on it.
Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.