GnuPG cheat sheet

A quick reference for GnuPG with the most important commands and options. Read it online below, or download the printable PDF.

Download PDF

Introduction

GnuPG (also known as GPG) is a free implementation of the OpenPGP standard. It is used to encrypt and sign data and communication.

Installation

Install GnuPG using your package manager or download it from gnupg.org.

Listing keys

Command Description
gpg --list-keys List public keys
gpg --list-secret-keys List secret keys
gpg --fingerprint Show the fingerprint of all keys
gpg --fingerprint <key> Show the fingerprint of a key

Key management

Command Description
gpg --generate-key Generate a new key pair
gpg --quick-generate-key Quickly generate a new key pair with default settings
gpg --full-generate-key Generate a new key pair with advanced settings
gpg --quick-add-uid <key> Add a user ID to a key
gpg --quick-revoke-uid <key> Revoke a user ID from a key
gpg --quick-set-expire <key> Set an expiration date for a key
gpg --edit-key <key> Enter the key edit menu
gpg --delete-key <key> Delete a key
gpg --delete-secret-key <key> Delete a secret key

Key edit menu

Command Description
list List keys and user IDs
uid <number> Select a user ID
key <number> Select a subkey
adduid Add a user ID
deluid Delete a user ID
addkey Add a subkey
delkey Delete a subkey
expire Set an expiration date
quit Quit the key edit menu
save Save changes and quit the key edit menu
help Show help

Importing & exporting keys

Command Description
gpg --import <file> Import a key from a file
gpg --export <key> Export a public key
gpg --export-secret-keys <key> Export a secret key
gpg --export --armor <key> Export a public key in ASCII armor format

Key servers

Command Description
gpg --send-keys <key> Upload a key to a key server
gpg --recv-keys <key> Download a key from a key server
gpg --search-keys <key> Search for a key on a key server
gpg --refresh-keys Download updates from a key server

Encrypting and decrypting

Command Description
gpg --encrypt --recipient <key> Encrypt a file with the recipient's public key
gpg --symmetric <file> Encrypt a file with a symmetric cipher
gpg --decrypt <file> Decrypt a file with your private key

Signing and verifying

Command Description
gpg --sign <file> Sign a file with your private key
gpg --clear-sign <file> Sign a file and add the signature in ASCII armor format
gpg --verify <file> Verify a file with the sender's public key

Smartcards / YubiKey

Command Description
gpg --card-status Show information about the smartcard
gpg --edit-card Enter the card edit menu

Card edit menu

Command Description
admin Enable administrative commands
name Change the cardholder's name
help Show help
quit Quit the card edit menu

GPG Agent

Command Description
gpg-agent --daemon Start the GPG agent