Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know which ssh key is used in my github account?

Tags:

github

ssh

When I go to the SSH keys page in my GitHub account, I see a key whose identity starts with "c5:42:08:9d:39:22..."

On my computer, in the ".ssh" folder, I have several files that look like public SSH keys, but none of them contains a string similar to the above. For example, one of the files "id_rsa.pub" contains a string that starts with "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA..." there are other similar files that probably represent different keys.

How can I identify which of the files, if any, represents the actual key that is in my github account?

like image 904
Erel Segal-Halevi Avatar asked Dec 24 '22 01:12

Erel Segal-Halevi


1 Answers

"c5:42:08:9d:39:22..." isn't the key, but rather the key's fingerprint. You can see your key's fingerprint using ssh-keygen:

ssh-keygen -lf ~/.ssh/id_rsa

Where

  • -l means we want to see the key's fingerprint
  • -f ~/.ssh/id_rsa is a path to the key whose fingerprint we want to see

On older versions of OpenSSH, you may need to also specify that you want the SHA256 fingerprint rather than another hash like MD5, since SHA256 is what GitHub shows in its web interface:

ssh-keygen -lf ~/.ssh/id_rsa -E sha256

You should get the same fingerprint from the public part as from the private part of the keypair.

like image 73
Chris Avatar answered Jan 18 '23 23:01

Chris