gpg2(1)
Encrypt, decrypt, and sign files or messages using GnuPG 2 with public-key cryptography.
Synopsis
gpg2 [OPTIONS] [FILE]...Description
GPG2 is the command-line interface to GnuPG (GNU Privacy Guard), a complete and free implementation of the OpenPGP standard. It allows you to encrypt and sign your data and communications, and features a versatile key management system. GPG2 uses public-key cryptography so you can communicate securely with people you've never met.
GPG2 differs from GPG (version 1) by using a separate daemon process (gpg-agent) for key management and by offering better support for smartcards, hardware tokens, and modern cryptographic standards. It is the recommended version for new installations.
Common options
| Flag | What it does |
|---|---|
-c, --symmetric | Encrypt with symmetric cipher (password-based) instead of public key |
-e, --encrypt | Encrypt data for specified recipient(s) |
-d, --decrypt | Decrypt encrypted data |
-s, --sign | Make a signature; used with -e to sign and encrypt |
--verify | Verify a signature on a file or detached signature |
-u, --local-user KEY-ID | Use specified key for signing |
-r, --recipient KEY-ID | Encrypt for specified recipient key |
--list-keys | Display all keys in your keyring |
--gen-key | Interactively generate a new key pair |
-o, --output FILE | Write output to specified file instead of stdout |
-a, --armor | Create ASCII-armored output (text-safe format) |
--trust-model=always | Skip trust checks (useful for automated scripts) |
Examples
Interactively create a new public-private key pair
gpg2 --gen-keyShow all public keys in your keyring
gpg2 --list-keysSymmetrically encrypt a file with a password; creates document.txt.gpg
gpg2 -c document.txtDecrypt an encrypted file and save to original filename
gpg2 -d document.txt.gpg -o document.txtEncrypt letter.txt for alice, ASCII-armored output to letter.txt.asc
gpg2 -e -r [email protected] -a letter.txt -o letter.txt.ascSign and encrypt file.pdf for bob using alice's key
gpg2 -s -e -r [email protected] -u [email protected] file.pdfVerify a detached signature against a document
gpg2 --verify signature.sig document.pdfPipe text into GPG, encrypt symmetrically with ASCII armor
echo 'secret message' | gpg2 -c -a -o message.gpg.txt