So, feel free to correct me if I am wrong but this is my current knowledge about ts:
- PGP and SSH both use asymmetric encryption; in other words there is always a public and private key.
- You can verify the sender with your public key if the sender signs whatever he sends with his private key.
- You tend to insert your public key into remote Git repository like Github etc.
So should your private key not be sufficient to verify your identity when you push commits? Why would you want to use PGP instead?
If you’re talking about
git config --global gpg.format ssh && git config --global user.signingKey ~/.ssh/your_key
and then signing your commit withgit commit --sign
then yeah, in modern times it’s very similar to PGP signing. There are a couple minor differences which make PGP a bit better:If you’re talking about using ssh for authentication to the git server, than it’s a different story. First of all, most git servers will actually accept it if you push commits committed by someone else (e.g. see this: https://github.com/jayphelps/git-blame-someone-else). (there’s a tangent about
Author:
vsCommitter:
that can be had, but in any case e.g. GitHub does not do any checks on either of those fields when you push commits there). And so, someone can just “pretend to be you” and push commits somewhere as though they have been created by you. There are of course some other mechanisms around that (e.g. access control to repositories) but it’s still a problem. PGP/SSH signing (as opposed to ssh authentication) is the most effective solution to that. If some commit has been signed by you, and everyone knows your public key, they can verify for themselves that you are the committer. GitHub has a way to (semi)-enforce that: if you add your GPG/SSH key as a signing key and enable “Vigilant mode” (" Flag unsigned commits as unverified "), all commits that have you asCommitter
which aren’t signed by your signing key will get marked as “Unverified” in their web interface and raise suspicion almost immediately.Of course this mechanism relies on GitHub (i.e. Microsoft) as the keyserver - they could in theory covertly replace your key with something else and most people would be none the wiser. Even if someone wanted to check themselves, for a project hosted on GitHub the most obvious way to find the persons PGP/SSH key is to request it from there (You can actually do that by going to
https://github.com/.gpg
andhttps://github.com/.ssh
- e.g. here’s my PGP public key: https://github.com/balsoft.gpg), so you have to trust them not to replace it. It’s better than nothing but not great. If you’re serious about key signing, publish your key on your own website, with as much of it controlled by you as possible (ideally on your own hardware), and advertise it widely. E.g. my key is available at https://balsoft.ru/key.Fyi for point 2, you can sign with SSH key stored on a hardware token (e.g., yubikey).