GPG

Generate GPG keypair

gpg --gen-key

Export the public key


::

gpg --armor --export user@example.com > user.gpg.pub

Encrypt a file

gpg --encrypt --recipient user@example.com --output <file>.gpg <file>

Decrypt a file


::

gpg --output <file> --decrypt <file>.gpg

Show key fingerprints


::

gpg --list-keys --fingerprint
# Show 32-bit fingerprints
gpg --list-keys --fingerprint --keyid-format=short


Verify signature of document


::

# Compressed, signed doc
gpg --output doc --decrypt doc.sig
# Detached signature
gpg --verify doc.sig doc

Generate a subkey


::

gpg --edit-key KEYNAME
gpg> addkey

List private keys


::

gpg --list-secret-keys
# A # after the letters sec means that the secret key is not usable

Deleting keys


::

gpg --delete-key USERNAME
gpg --delete-secret-key USERNAME

Links