Skip to main content

PGP

Last updated: Aug 5, 2020 ·
Posted in wiki#notes

GnuPG

Official documentation

Generate a GPG key

gpg --full-generate-key
gpg --gen-key # Equivalent to above

Generate a revocation certificate

gpg --gen-revoke --output revoke.asc <user ID>

Ways to specify a user ID

List all keys

gpg --list-secret-keys
gpg --list-key # Equivalent to above
gpg -k # Equivalent to above
gpg --list-secret-keys --keyid-format=long # List the long form of the keys

Export a public key

gpg --armor --export <user ID> # Print the GPG public key in ASCII armor format
gpg --output username.gpg --export <user ID> # Export in binary format

Import a public key

gpg --import alice.gpg

Export a fingerprint

gpg --fingerprint <user ID>

Encrypt a document

gpg --output doc.gpg --encrypt --recipient <recipient_email> doc

Decrypt a document

gpg --output doc --decrypt doc.gpg