Skip to content

Instantly share code, notes, and snippets.

@JavierLuna
Created August 24, 2019 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JavierLuna/0336c7bdd35002f21881964f8cd37bf9 to your computer and use it in GitHub Desktop.
Save JavierLuna/0336c7bdd35002f21881964f8cd37bf9 to your computer and use it in GitHub Desktop.
GPG quick & easy

GPG quick and straight to the point

(Some systems use gpg2 instead of gpg, same thing but different name)

Create key pair

gpg --full-gen-key. RSA and RSA (the default) and use 4096 lenght.

List all the keys on your machine

gpg --list-keys --keyid-format LONG. The $ID I'll be refering from now on goes after the pub rsa4096/ part.

Echo public key

gpg --armor --export $ID. This will echo something like:

-----BEGIN PGP PUBLIC KEY BLOCK-----
sdafasdfasdfasdfoiiowenm3245235t90adwnef
BUNCH OF RANDOM HACKER STUF
aoisdnfo0iasdnofino4in23otinoijaf09dscm90432
-----END PGP PUBLIC KEY BLOCK-----

Now you can add the whole thing (the ---BEGIN--- and --END-- part too) to your repository server as your GPG key.

Sign commits

git commit -S -m "message". See the -S option.

To make signing a default, use git config --global commit.gpgsign true.

Sign & verify tags

To sign a tag: git tag -s mytag Verify a tag: git tag -v mytag

Export/Import key to/from other machine

Export: gpg --export-secret-keys $ID > my-private-key.asc Import: gpg --import my-private-key.asc

A more secure setup

This will be my setup as I'm new to GPG and will want to get more comfortable with this before setting a more complex and secure system, like the one described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment