GPG vs SSH keys

SecurityGithubSshSsh KeysGnupg

Security Problem Overview


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.

Security Solutions


Solution 1 - Security

> 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.


Vishwas M.R points out in the comments to "Why would I sign my git commits with a GPG key when I already use an SSH key to authenticate myself when I push?"

> When you authenticate to Github with your SSH key, that authentication doesn't become part of the repository in any meaningful or lasting way.
It causes Github to give you access for the moment, but it doesn't prove anything to anyone who is not Github. > > When you GPG-sign a Git tag, that tag is part of the repository, and can be pushed to other copies of the repository.
Thus, other people who clone your repository can verify the signed tag, assuming that they have access to your public key and reason to trust it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDomenickView Question on Stackoverflow
Solution 1 - SecurityVonCView Answer on Stackoverflow