76

On GitHub, I want to add a key to associate my computer with my account and I am given two options: create an SSH or a GPG key.

What is the difference between the two keys? and is there a preferred one to use?
I understand how to create both by following the guide on the site but I don't know which one is better to use.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
Domenick
  • 1,220
  • 2
  • 8
  • 20
  • 9
    They are used for different things on github. SSH is used for authentication while GPG is used for signing tags and commits. – Xaqron Jul 18 '18 at 23:39

1 Answers1

40

I want to add a key to associate my computer with my account and I am given two options

You will need at least the SSH one, if you want to push back to your repository, using an SSH URL (since the public SSH key will authenticate you).
Start with SSH. See "Connecting to GitHub with SSH".

Later, you can use GPG to sign commits.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 1
    Can I replace my SSH key with my GPG key? – daraul Oct 25 '19 at 14:41
  • 2
    @daraul As I mentioned in 2017: https://stackoverflow.com/a/45120525/6309, you could technically replace your SSH key be a gpg one (https://superuser.com/a/390176/141), but that is not very convenient, or what a GPG key is used for usually. – VonC Oct 25 '19 at 17:00
  • On gpg signing commits: https://stackoverflow.com/a/60456524/6309 (Eclipse) and https://stackoverflow.com/a/51919818/6309 (x509 instead of openpgp) – VonC Mar 16 '20 at 22:05