GitHub SSH Keys: Public Key vs Fingerprint
When using multiple GitHub accounts, it is easy to lose track of which key in ~/.ssh belongs to which profile.
The key point: GitHub shows the SSH fingerprint, not sha256sum of *.pub file.
§Public key vs fingerprint
A .pub file contains the full public key in text form, usually like this:
1 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... alice@laptop |
ssh-ed25519is the key typeAAAAC3...is the Base64-encoded key materialalice@laptopis a comment
A fingerprint is a short identifier derived from the key material. Example:
1 | SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
These commands do different things:
sha256sum ~/.ssh/id_ed25519.pubhashes the raw file bytes (including comment/newline)ssh-keygen -lf ~/.ssh/id_ed25519.pub -E sha256computes the SSH key fingerprint GitHub-style
The second command computes the fingerprint GitHub displays.
§How to match local keys to GitHub profiles
- List local public keys:
1 | ls ~/.ssh/*.pub |
- Print fingerprints for each one:
1 | for key in ~/.ssh/*.pub; do |
Example output:
1 | 256 SHA256:abc...123 alice@personal-laptop (ED25519) |
- In each GitHub account, open Settings -> SSH and GPG keys and compare the
SHA256:...value.
A matching fingerprint identifies the local key for that GitHub profile.
§TL;DR
Use this command to compare with GitHub:
1 | ssh-keygen -lf ~/.ssh/id_ed25519.pub -E sha256 |
Do not use sha256sum if the goal is to match GitHub’s SSH key display.