$linuxjunkies
>

gpg2(1)

Encrypt, decrypt, and sign files or messages using GnuPG 2 with public-key cryptography.

UbuntuDebianFedoraArch

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

FlagWhat it does
-c, --symmetricEncrypt with symmetric cipher (password-based) instead of public key
-e, --encryptEncrypt data for specified recipient(s)
-d, --decryptDecrypt encrypted data
-s, --signMake a signature; used with -e to sign and encrypt
--verifyVerify a signature on a file or detached signature
-u, --local-user KEY-IDUse specified key for signing
-r, --recipient KEY-IDEncrypt for specified recipient key
--list-keysDisplay all keys in your keyring
--gen-keyInteractively generate a new key pair
-o, --output FILEWrite output to specified file instead of stdout
-a, --armorCreate ASCII-armored output (text-safe format)
--trust-model=alwaysSkip trust checks (useful for automated scripts)

Examples

Interactively create a new public-private key pair

gpg2 --gen-key

Show all public keys in your keyring

gpg2 --list-keys

Symmetrically encrypt a file with a password; creates document.txt.gpg

gpg2 -c document.txt

Decrypt an encrypted file and save to original filename

gpg2 -d document.txt.gpg -o document.txt

Encrypt letter.txt for alice, ASCII-armored output to letter.txt.asc

gpg2 -e -r [email protected] -a letter.txt -o letter.txt.asc

Sign and encrypt file.pdf for bob using alice's key

gpg2 -s -e -r [email protected] -u [email protected] file.pdf

Verify a detached signature against a document

gpg2 --verify signature.sig document.pdf

Pipe text into GPG, encrypt symmetrically with ASCII armor

echo 'secret message' | gpg2 -c -a -o message.gpg.txt

Related commands