Guide

GNU Privacy Guard

Notes on creating keys, signing files, and encrypting with GnuPG.

On this page

GNU Privacy Guard

GNU 4 pillars:

I. Key Generation

To generate the keys use, and follow the step, choose a good passphrase and high key length.

gpg --full-gen-key
# get info about your keys
gpg --list-keys
gpg --list-signatures

Here are what the abbr means:

  • sec: secret key
  • ssb: secret subkey
  • pub: public key
  • sub: public subkey

You can export you own public (or private) key.

gpg --armor --export <ID> > you-public.key
gpg --armor --export-secret-keys <ID> > your-private.key

Create a revocation certificate, to revoke your key when lost or compromised

gpg --output revoke.asc --gen-revoke <ID>
# To revoke it
gpg --edit-key

Setup subkeys: …

Using gpg

Signing files

# text messages
gpg --clearsign message.txt
gpg --verify message.txt.asc # verify signed files using sender public key.
# binary files
gpg --armor --detach-sign archive.tar.gz
gpg --verify archive.tar.gz.asc archive.tar.gz
gpg --armor --recipient 695195A5 --encrypt secret-message.txt

File encryption

gpg --armor --recipient <ID> --encrypt secret-message.txt
gpg --decrypt secret-message.txt.asc
# sign and encrypt
gpg --recipient <ID> --recipient <ID> \
    --armor --sign --encrypt secret-message.txt

II. Key Storage and Management

III. Encrypting

IV. Singing