GPG(1)

๐Ÿ’– GPG(1) ๐Ÿ’–

the GNU Privacy Guard 2.4 era, bestie โ€” OpenPGP encryption and signing tool

okay so. welcome to gpg, the OpenPGP part of the GNU Privacy Guard (aka GnuPG), and honestly she's a whole legend. she does digital encryption and signing like the OpenPGP standard says, and she's got complete key management plus all the bells and whistles you'd expect from a full OpenPGP implementation. no notes. ๐Ÿ‘‘


โœจ NAME โœจ

gpg โ€” OpenPGP encryption and signing tool. that's her. that's the whole vibe.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

gpg [--homedir dir] [--options file] [options] command [args]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so gpg is the OpenPGP part of GnuPG, and she's your girl for digital encryption and signing services using the OpenPGP standard. full key management? yes. all the bells and whistles you'd expect from a full OpenPGP implementation? also yes. she ate. ๐Ÿ’…

now, there are two main versions of GnuPG, and you gotta know which one you're dealing with:

  • GnuPG 2.x โ€” supports modern encryption algorithms, so prefer this one, fr fr.
  • GnuPG 1.x โ€” you only need her if your platform doesn't support GnuPG 2.x, or if you need support for some features that GnuPG 2.x has deprecated, e.g., decrypting data created with PGP-2 keys.

and if you're out here looking for version 1 of GnuPG? you might find that version installed under the name gpg1. iykyk. ๐Ÿซถ


โญ RETURN VALUE โญ

the program returns:

  • 0 โ€” if there are no severe errors
  • 1 โ€” if at least a signature was bad
  • other error codes โ€” for fatal errors
โš ๏ธ okay this part is important, bestie: signature verification requires exact knowledge of what has been signed and by whom it has been signed. so using only the return code is not an appropriate way to verify a signature by a script. nope. either make proper use of the status codes, or use the gpgv tool, which has been designed to make signature verification easy for scripts. ๐Ÿ™ˆ

๐Ÿ’€ WARNINGS ๐Ÿ’€

use a good password for your user account, and make sure that all security issues are always fixed on your machine. also, employ diligent physical protection for your machine. consider using a good passphrase as a last-resort protection for your secret key in case your machine gets stolen. it is important that your secret key is never leaked. using an easy-to-carry-around token or smartcard with the secret key is often advisable. ๐Ÿ”ฅ

if you're going to verify detached signatures, make sure the program knows about it โ€” either give both filenames on the command line, or use - to specify STDIN. don't leave her guessing. ๐Ÿ˜ญ

for scripted or other unattended use of gpg, make sure to use the machine-parseable interface and not the default interface, which is intended for direct use by humans. the machine-parseable interface provides a stable and well documented API independent of the locale or future changes of gpg. to enable this interface, use the options --with-colons and --status-fd. for certain operations the option --command-fd may come in handy too. see this man page and the file DETAILS for the specification of the interface. ๐Ÿ“š

also note that the GnuPG "info" pages as well as the PDF version of the GnuPG manual feature a chapter on unattended use of GnuPG. and as an alternative, the library GPGME can be used as a high-level abstraction on top of that interface. options, options, options. ๐ŸŽ€


๐ŸŒˆ INTEROPERABILITY ๐ŸŒˆ

GnuPG tries to be a very flexible implementation of the OpenPGP standard. in particular, GnuPG implements many of the optional parts of the standard, such as the SHA-512 hash, and the ZLIB and BZIP2 compression algorithms. ๐Ÿ’…

but โ€” and this is the tea โ€” it is important to be aware that not all OpenPGP programs implement these optional algorithms, and that by forcing their use via the --cipher-algo, --digest-algo, --cert-digest-algo, or --compress-algo options in GnuPG, it is possible to create a perfectly valid OpenPGP messageโ€ฆ but one that cannot be read by the intended recipient. ๐Ÿ˜ญ yes, you made a valid message. no, they can't open it. bestie, please.

there are dozens of variations of OpenPGP programs available, and each supports a slightly different subset of these optional algorithms. for example, until recently, no (unhacked) version of PGP supported the BLOWFISH cipher algorithm. a message using BLOWFISH simply could not be read by a PGP user. that's the situation. ๐Ÿซ 

by default, GnuPG uses the standard OpenPGP preferences system that will always do the right thing and create messages that are usable by all recipients, regardless of which OpenPGP program they use. only override this safe default if you really know what you are doing. periodt.

if you absolutely must override the safe default, or if the preferences on a given key are invalid for some reason, you are far better off using the --pgp6, --pgp7, or --pgp8 options. these options are safe, as they do not force any particular algorithms in violation of OpenPGP โ€” instead they reduce the available algorithms to a "PGP-safe" list. slay. โœจ


๐Ÿ‘‘ COMMANDS ๐Ÿ‘‘

okay so commands are not distinguished from options, except for the fact that only one command is allowed. generally speaking, irrelevant options are silently ignored, and may not be checked for correctness. she's chill like that. ๐Ÿ™ˆ

gpg may be run with no commands. in this case she will print a warning and perform a reasonable action depending on the type of file she's given as input โ€” an encrypted message is decrypted, a signature is verified, a file containing keys is listed, etc. main character energy, honestly. ๐Ÿ’–

๐Ÿ’ก if you run into any problems, please add the option --verbose to the invocation to see more diagnostics. she'll tell you everything.

๐ŸŽ€ Commands not specific to the function

  • --version โ€” print the program version and licensing information. note that you cannot abbreviate this command. sorry babe.
  • --help, -h โ€” print a usage message summarizing the most useful command-line options. note that you cannot arbitrarily abbreviate this command (though you can use its short form -h). ๐Ÿซถ
  • --warranty โ€” print warranty information.
  • --dump-options โ€” print a list of all available options and commands. note that you cannot abbreviate this command either.

๐Ÿ’… Commands to select the type of operation

  • --sign, -s โ€” sign a message. this command may be combined with --encrypt (to sign and encrypt a message), --symmetric (to sign and symmetrically encrypt a message), or both --encrypt and --symmetric (to sign and encrypt a message that can be decrypted using a secret key or a passphrase). the signing key is chosen by default or can be set explicitly using the --local-user and --default-key options. iconic combo potential. ๐Ÿ”ฅ
  • --clear-sign, --clearsign โ€” make a cleartext signature. the content in a cleartext signature is readable without any special software โ€” OpenPGP software is only needed to verify the signature. cleartext signatures may modify end-of-line whitespace for platform independence and are not intended to be reversible. the signing key is chosen by default or can be set explicitly using the --local-user and --default-key options. ๐ŸŽ€
  • --detach-sign, -b โ€” make a detached signature.
  • --encrypt, -e โ€” encrypt data to one or more public keys. this command may be combined with --sign (to sign and encrypt a message), --symmetric (to encrypt a message that can be decrypted using a secret key or a passphrase), or --sign and --symmetric together (for a signed message that can be decrypted using a secret key or a passphrase). --recipient and related options specify which public keys to use for encryption. ๐Ÿ’–
  • --symmetric, -c โ€” encrypt with a symmetric cipher using a passphrase. the default symmetric cipher used is AES-128, but may be chosen with the --cipher-algo option. this command may be combined with --sign (for a signed and symmetrically encrypted message), --encrypt (for a message that may be decrypted via a secret key or a passphrase), or --sign and --encrypt together (for a signed message that may be decrypted via a secret key or a passphrase). gpg caches the passphrase used for symmetric encryption so that a decrypt operation may not require that the user needs to enter the passphrase. the option --no-symkey-cache can be used to disable this feature. ๐Ÿ’€
  • --store โ€” store only (make a simple literal data packet). lowkey minimal. ๐ŸŒธ
  • --decrypt, -d โ€” decrypt the file given on the command line (or STDIN if no file is specified) and write it to STDOUT (or the file specified with --output). if the decrypted file is signed, the signature is also verified. this command differs from the default operation, as it never writes to the filename which is included in the file and it rejects files that don't begin with an encrypted message. strict queen. ๐Ÿ‘‘
  • --verify โ€” assume that the first argument is a signed file and verify it without generating any output. with no arguments, the signature packet is read from STDIN. if only one argument is given, the specified file is expected to include a complete signature.

with more than one argument, the first argument should specify a file with a detached signature and the remaining files should contain the signed data. to read the signed data from STDIN, use - as the second filename. for security reasons, a detached signature will not read the signed material from STDIN if not explicitly specified. ๐Ÿซถ

โš ๏ธ Note: if the option --batch is not used, gpg may assume that a single argument is a file with a detached signature, and it will try to find a matching data file by stripping certain suffixes. using this historical feature to verify a detached signature is strongly discouraged; you should always specify the data file explicitly. fr fr.
โš ๏ธ Note: when verifying a cleartext signature, gpg verifies only what makes up the cleartext signed data and not any extra data outside of the cleartext signature or the header lines directly following the dash marker line. the option --output may be used to write out the actual signed data, but there are other pitfalls with this format as well. it is suggested to avoid cleartext signatures in favor of detached signatures. ๐Ÿ™ˆ
โš ๏ธ Note: with option --batch, the verification of signatures stops at the first bad signature. this is a safe default for unattended processing, but sometimes a status for all signatures is needed. to override this early bailout, use the option --proc-all-sigs. ๐Ÿ’…
โš ๏ธ Note: to check whether a file was signed by a certain key, the option --assert-signer can be used. as an alternative, the gpgv tool can be used. gpgv is designed to compare signed data against a list of trusted keys and returns with success only for a good signature. it has its own manual page. โœจ
  • --multifile โ€” this modifies certain other commands to accept multiple files for processing on the command line, or read from STDIN with each filename on a separate line. this allows for many files to be processed at once. --multifile may currently be used along with --verify, --encrypt, and --decrypt. note that --multifile --verify may not be used with detached signatures. ๐Ÿฆ‹
  • --verify-files โ€” identical to --multifile --verify. twin energy. ๐ŸŽ€
  • --encrypt-files โ€” literally just --multifile --encrypt wearing a different outfit ๐Ÿ’… same thing, no cap.
  • --decrypt-files โ€” and this one is --multifile --decrypt. identical twin energy. ๐Ÿซถ
  • --list-keys, -k, --list-public-keys โ€” lists the keys you asked for. and if you didn't ask for any? it just dumps all the keys from the public keyrings you've got configured. iconic behavior tbh.
ok bestie this is the important bit: never put the output of this command in scripts or other programs ๐Ÿ˜ญ it's for humans only and the format is like, extremely likely to change on you. if you need machine-parseable stuff, use --with-colons โ€” that output is stable and meant for scripts and programs. periodt.
  • --list-secret-keys, -K โ€” lists the secret keys you specified, and if you specified none, it lists every known secret key. here's the decoding guide ๐Ÿ•ต๏ธโ€โ™€๏ธ a # right after the initial sec or ssb tags means that secret key or subkey is currently not usable โ€” we also say the key has been "taken offline" (like, say, a primary key can be taken offline by exporting it with --export-secret-subkeys). and a > after those tags means the key lives on a smartcard ๐ŸŽ€ see also --list-keys.
  • --check-signatures, --check-sigs โ€” same as --list-keys but it also verifies and lists the key signatures โœจ heads up tho: for performance reasons the revocation status of a signing key is not shown. this command does exactly the same thing as --list-keys with --with-sig-check.

the verification status shows up as a flag directly after the "sig" tag (so, before the flags described below ๐Ÿ‘‡). a "!" means the signature verified successfully, a "-" means bad signature, and a "%" means an error happened while checking it (like, an unsupported algorithm, yikes). signatures where the public key isn't available just aren't listed โ€” if you wanna see their keyids, use --list-sigs.

for each signature listed there are several flags sitting between the signature status flag and the keyid, and they're giving extra info about each key signature. from left to right: ๐ŸŽ€

  • the numbers 1-3 for certificate check level (see --ask-cert-level)
  • "L" for a local / non-exportable signature (see --lsign-key)
  • "R" for a nonRevocable signature (see the --edit-key command "nrsign")
  • "P" for a signature containing a policy URL (see --cert-policy-url)
  • "N" for a signature containing a notation (see --cert-notation)
  • "X" for an eXpired signature (see --ask-cert-expire)
  • the numbers 1-9, or "T" for 10 and above, to show trust signature levels (see the --edit-key command "tsign")
  • --locate-keys, --locate-external-keys โ€” locates the keys you pass as arguments ๐Ÿ” it basically runs the same algorithm gpg uses when locating keys for encryption, so you can peep at which keys gpg might actually use. specifically, external methods as defined by --auto-key-locate get used to locate a key if the arguments contain valid mail addresses. only public keys get listed.

the --locate-external-keys variant doesn't consider a locally existing key, so you can use it to force a refresh of a key through the defined external methods ๐Ÿ’ช if you give a fingerprint and the methods defined by --auto-key-locate define LDAP servers, the key gets fetched from those resources; defined non-LDAP keyservers are skipped.

  • --show-keys โ€” takes OpenPGP keys as input and prints info about them the same way --list-keys does for locally stored keys. bonus: the list options show-unusable-uids, show-unusable-subkeys, show-notations and show-policy-urls are also enabled ๐ŸŽ and as usual for automated processing, pair this one with --with-colons.
  • --fingerprint โ€” lists all keys (or just the ones you specified) along with their fingerprints. same output as --list-keys but with an extra line containing the fingerprint ๐ŸŒˆ can also be combined with --check-signatures. if you give this command twice, the fingerprints of all secondary keys get listed too. also, it forces pretty printing of fingerprints if the keyid format has been set to "none" โœจ
  • --list-packets โ€” lists only the sequence of packets. this one is purely for debugging, bestie ๐Ÿ”ง when used with --verbose the actual MPI values get dumped, not just their lengths. and note that the output of this command may change with new releases ๐Ÿ‘€
  • --edit-card, --card-edit โ€” brings up a menu to work with a smartcard ๐Ÿ’ณ the "help" subcommand gives you an overview of the available commands. for the detailed description, go read the Card HOWTO at https://gnupg.org/documentation/howtos.html#GnuPG-cardHOWTO ๐Ÿงš also note: the "openpgp" command switches to the OpenPGP application of cards that by default present a different application (like PIV).
  • --card-status โ€” shows you the content of the smart card ๐ŸŽ€
  • --change-pin โ€” brings up a menu so you can change the PIN of a smartcard. this same functionality also lives as the "passwd" subcommand inside --edit-card ๐Ÿ’…
  • --delete-keys name โ€” removes a key from the public keyring. in batch mode you either need --yes or the key has to be specified by fingerprint โ€” that's a safeguard against accidentally deleting a bunch of keys at once ๐Ÿ˜ญ and if you use the exclamation mark syntax with the fingerprint of a subkey, only that subkey gets deleted; if you use the exclamation mark with the fingerprint of the primary key, the entire public key gets deleted ๐Ÿ’€
  • --delete-secret-keys name โ€” removes a key from the secret keyring. in batch mode the key must be specified by fingerprint. --yes can be used to tell gpg-agent not to ask for confirmation. this extra pre-caution exists because gpg can't be sure that the secret key (as controlled by gpg-agent) is only used for the given OpenPGP public key ๐Ÿ‘€ if you use the exclamation mark syntax with the fingerprint of a subkey, only the secret part of that subkey gets deleted; if you use the exclamation mark with the fingerprint of the primary key, only the secret part of the primary key gets deleted.
  • --delete-secret-and-public-key name โ€” same as --delete-key, but if a secret key exists it gets removed first. in batch mode the key must be specified by fingerprint. --yes can be used to tell gpg-agent not to ask for confirmation ๐Ÿซถ
  • --export โ€” exports either all keys from all keyrings (the default keyring plus any registered via --keyring), or, if you give at least one name, the keys with that name. exported keys go to STDOUT or to the file given with --output. team it up with --armor to mail those keys ๐Ÿ’Œ
  • --send-keys keyIDs โ€” like --export but it sends the keys to a keyserver. fingerprints work instead of key IDs. do not send your complete keyring to a keyserver โ€” only pick the keys that are new or changed by you, ok? ๐Ÿ™ if you give no keyIDs, gpg does nothing.
โš ๏ธ take care: keyservers are by design write only systems, so it is not possible to ever delete keys once they've been sent to a keyserver. gone forever. no takebacks. ๐Ÿ’€
  • --export-secret-keys, --export-secret-subkeys โ€” same as --export but exports the secret keys instead. exported keys go to STDOUT or to the file given with --output. this is often used with --armor so you can easily print the key for a paper backup ๐Ÿ–จ๏ธ โ€” though the external tool paperkey does a better job of making backups on paper. and note that exporting a secret key can be a security risk if the exported keys get sent over an insecure channel ๐Ÿ˜ฌ

the second form has the special property of rendering the secret part of the primary key useless ๐Ÿซ  this is a GNU extension to OpenPGP and other implementations can't be expected to successfully import such a key. its intended use is generating a full key with an additional signing subkey on a dedicated machine, then exporting the key without the primary key to the main machine.

gpg may ask you to enter the passphrase for the key โ€” that's required because the internal protection method of the secret key differs from the one specified by the OpenPGP protocol ๐Ÿ”

  • --export-ssh-key โ€” exports a key in the OpenSSH public key format ๐Ÿš it requires you to specify one key the usual way, and it exports the latest valid subkey that has authentication capability to STDOUT or to the file given with --output. that output can be added straight into ssh's โ€˜authorized_keyโ€™ file โœจ

if you specify the key to export using a key ID or a fingerprint with an exclamation mark (!) suffix, you can export a specific subkey or the primary key. this doesn't even require the key to have the authentication capability flag set ๐Ÿ‘‘

  • --import, --fast-import โ€” imports/merges keys. adds the given keys to the keyring. the fast version is currently just a synonym ๐Ÿคทโ€โ™€๏ธ

there are a few other options controlling how this command works, and the most notable is the --import-options merge-only option, which doesn't insert new keys but only merges new signatures, user-IDs and subkeys ๐Ÿ’…

  • --receive-keys keyIDs, --recv-keys keyIDs โ€” imports the keys with the given keyIDs from a keyserver ๐Ÿ“ฅ
  • --refresh-keys โ€” requests updates from a keyserver for keys that already exist on the local keyring. super useful for updating a key with the latest signatures, user IDs, etc. ๐ŸŒธ calling it with no arguments refreshes the entire keyring, so likeโ€ฆ maybe grab a snack first ๐Ÿ“
  • --search-keys names โ€” bestie, this one hunts the keyserver for the names you give it. Give it multiple names and it'll glue them all together into one big search string for the keyserver. โš ๏ธ heads up tho: keyservers search names in a different and simpler way than gpg does, so the glow-up move is to just use a mail address. And lowkey because of data privacy reasons, keyservers may not even allow searching by user id or mail address at all, which means they might only give you results when you use them with the --recv-key command to search by key fingerprint or keyid. iykyk ๐Ÿ’…
  • --fetch-keys URIs โ€” grabs keys living at the URIs you point at. โœจ Ngl, different installations of GnuPG may support different protocols (HTTP, FTP, LDAP, etc.), so don't come for me if your setup is picky. When you're using HTTPS, the system provided root certificates are the ones used by this command. ๐Ÿฆ‹
  • --update-trustdb โ€” trust database maintenance era ๐Ÿ’–. This command iterates over all the keys and builds the Web of Trust. It's interactive because it may have to ask you for the "ownertrust" values for keys โ€” yeah, you. The user has to give an estimation of how far she trusts the owner of the displayed key to correctly certify (sign) other keys. GnuPG only asks for the ownertrust value if it hasn't been assigned to a key yet, so no repeats. And using the --edit-key menu, the assigned value can be changed at any time. slay ๐Ÿ”ฅ
  • --check-trustdb โ€” same trust database maintenance but without user interaction. From time to time the trust database must be updated so that expired keys or signatures and the resulting changes in the Web of Trust can be tracked. Normally, GnuPG will calculate when this is required and do it automatically, unless --no-auto-check-trustdb is set. This command lets you force a trust database check at any time. The processing is identical to that of --update-trustdb but it skips keys with a not yet defined "ownertrust" โ€” no awkward questions. ๐Ÿ™ˆ

For use with cron jobs, this command can be used together with --batch, in which case the trust database check is done only if a check is needed. To force a run even in batch mode, add the option --yes. ๐Ÿ‘‘

  • --export-ownertrust โ€” sends the ownertrust values to STDOUT. This is useful for backup purposes as these values are the only ones which can't be re-created from a corrupted trustdb. iconic honestly. Example:
gpg --export-ownertrust > otrust.txt
  • --import-ownertrust โ€” updates the trustdb with the ownertrust values stored in files (or STDIN if not given); existing values will be overwritten. In case of a severely damaged trustdb and if you have a recent backup of the ownertrust values (e.g. in the file 'otrust.txt'), you may re-create the trustdb using these commands:
cd ~/.gnupg
rm trustdb.gpg
gpg --import-ownertrust < otrust.txt
  • --rebuild-keydb-caches โ€” when updating from version 1.0.6 to 1.0.7 this command should be used to create signature caches in the keyring. It might be handy in other situations too. ๐Ÿงš
  • --print-md algo
  • --print-mds โ€” prints the message digest of algorithm algo for all given files or STDIN. With the second form (or a deprecated "*" for algo), digests for all available algorithms are printed. ๐ŸŒˆ
  • --gen-random 0|1|2|16|30 count โ€” emits count random bytes of the given quality level 0, 1 or 2. If count is not given or zero, an endless sequence of random bytes will be emitted. If used with --armor the output will be base64 encoded. The special level 16 uses a quality level of 1 and outputs an endless stream of hex-encoded octets. The special level 30 outputs random as 30 zBase-32 characters. chaotic and I love it ๐Ÿ’€
  • --gen-prime mode bits โ€” Use the source, Luke :-). The output format is subject to change with any release. fr fr, that's all she wrote on this one ๐Ÿซถ
  • --enarmor
  • --dearmor โ€” packs or unpacks an arbitrary input into/from an OpenPGP ASCII armor. This is a GnuPG extension to OpenPGP and in general not very useful (ngl it's giving niche). The --dearmor command can also be used to dearmor PEM armors. ๐ŸŽ€
  • --unwrap โ€” this option modifies the command --decrypt to output the original message with the encryption layer removed. So the output will be an OpenPGP data structure, which often means a signed OpenPGP message. Note that this option may or may not remove a compression layer which is often found beneath the encryption layer โ€” yeah, it's a maybe, don't @ me. ๐Ÿฆ‹
  • --tofu-policy {auto|good|unknown|bad|ask} keys โ€” sets the TOFU policy for all the bindings associated with the specified keys. For more information about the meaning of the policies, see: [trust-model-tofu]. The keys may be specified either by their fingerprint (preferred ๐Ÿ’–) or their keyid. ๐Ÿ‘‘

๐ŸŒธ How to manage your keys ๐ŸŒธ

This section explains the main commands for key management. Let's get into it bestie, this is the good part โœจ

  • --quick-generate-key user-id [algo [usage [expire]]]
  • --quick-gen-key โ€” a simple command to generate a standard key with one user id. In contrast to --generate-key the key is generated directly without the need to answer a bunch of prompts. Unless the option --yes is given, the key creation will be canceled if the given user id already exists in the keyring. ๐Ÿ˜Œ

If invoked directly on the console without any special options an answer to a Continue? style confirmation prompt is required. In case the user id already exists in the keyring, a second prompt to force the creation of the key will show up. (double-checking you, respectfully ๐Ÿ’…)

If algo or usage are given, only the primary key is created and no prompts are shown. To specify an expiration date but still create a primary and subkey, use default or future-default for algo and default for usage. For a description of these optional arguments see the command --quick-add-key. The usage accepts also the value cert, which can be used to create a certification only primary key; the default is to a create certification and signing key.

The expire argument can be used to specify an expiration date for the key. Several formats are supported; commonly the ISO formats YYYY-MM-DD or YYYYMMDDThhmmss are used. To make the key expire in N seconds, N days, N weeks, N months, or N years use seconds=N, Nd, Nw, Nm, or Ny respectively. Not specifying a value, or using - results in a key expiring in a reasonable default interval. The values never, none can be used for no expiration date. ๐ŸŒˆ

If this command is used with --batch, --pinentry-mode has been set to loopback, and one of the passphrase options (--passphrase, --passphrase-fd, or --passphrase-file) is used, the supplied passphrase is used for the new key and the agent does not ask for it. To create a key without any protection --passphrase '' may be used. ๐Ÿ”ฅ

To create an OpenPGP key from the keys available on the currently inserted smartcard, the special string card can be used for algo. If the card features an encryption and a signing key, gpg will figure them out and create an OpenPGP key consisting of the usual primary key and one subkey. This works only with certain smartcards. Note that the interactive --full-gen-key command allows one to do the same but with greater flexibility in the selection of the smartcard keys. ๐ŸŽ€

Note that it is possible to create a primary key and a subkey using non-default algorithms by using default and changing the default parameters using the option --default-new-key-algo.

  • --quick-set-expire fpr expire [*|subfprs] โ€” with two arguments given, directly set the expiration time of the primary key identified by fpr to expire. To remove the expiration time 0 can be used. With three arguments and the third given as an asterisk, the expiration time of all non-revoked and not yet expired subkeys are set to expire. With more than two arguments and a list of fingerprints given for subfprs, all non-revoked subkeys matching these fingerprints are set to expire. one command, so many moods ๐Ÿ’…
  • --quick-add-key fpr [algo [usage [expire]]] โ€” directly add a subkey to the key identified by the fingerprint fpr. Without the optional arguments an encryption subkey is added. If any of the arguments are given a more specific subkey is added.

algo may be any of the supported algorithms or curve names given in the format as used by key listings. To use the default algorithm the string default or - can be used. Supported algorithms are rsa, dsa, elg, ed25519, cv25519, and other ECC curves. For example the string rsa adds an RSA key with the default key length; a string rsa4096 requests that the key length is 4096 bits. The string future-default is an alias for the algorithm which will likely be used as default algorithm in future versions of gpg. To list the supported ECC curves the command gpg --with-colons --list-config curve can be used. ๐Ÿฆ‹

Depending on the given algo the subkey may either be an encryption subkey or a signing subkey. If an algorithm is capable of signing and encryption and such a subkey is desired, a usage string must be given. This string is either default or - to keep the default, or a comma delimited list (or space delimited list) of keywords: sign for a signing subkey, auth for an authentication subkey, and encr for an encryption subkey (encrypt can be used as alias for encr). The valid combinations depend on the algorithm. ๐Ÿ‘‘

The expire argument can be used to specify an expiration date for the key. Several formats are supported; commonly the ISO formats YYYY-MM-DD or YYYYMMDDThhmmss are used. To make the key expire in N seconds, N days, N weeks, N months, or N years use seconds=N, Nd, Nw, Nm, or Ny respectively. Not specifying a value, or using - results in a key expiring in a reasonable default interval. The values never, none can be used for no expiration date. ๐ŸŒธ

  • --quick-add-adsk fpr adskfpr โ€” bestie, this one just directly adds an Additional Decryption Subkey to the key whose fingerprint is fpr. And adskfpr is the fingerprint of another key's encryption subkey โ€” yeah, a subkey, because by default a primary key has no encryption capability, so that's just how it be. Wanna see those subkey fingerprints? Use --with-subkey-fingerprint with a list command. โœจ And here's the cute shortcut: if you pass the string "default" for adskfpr, then every single missing ADSK configured with --default-new-key-adsk gets added. Obsessed with the efficiency honestly.
  • --generate-key, --gen-key โ€” makes a brand new key pair using the current default parameters. This is the standard command to create a new key, main character energy ๐Ÿ‘‘. And not me reminding you: alongside the key, a revocation certificate gets created and stashed in the openpgp-revocs.d directory below the GnuPG home directory. So it's already there for you, no cap.
  • --full-generate-key, --full-gen-key โ€” same idea but with dialogs for all the options. It's the extended version of --generate-key, i.e. the one that asks you everything rather than vibing with defaults.

Also โ€” there's a feature that lets you create keys in batch mode. Peep the manual section ``Unattended key generation'' for how to use that, iykyk.

  • --generate-revocation name, --gen-revoke name โ€” generates a revocation certificate for the complete key. If you only wanna revoke a subkey or a key signature, use the --edit command instead, bestie.

Okay important thing so listen up ๐Ÿ‘‘: this command merely creates the revocation certificate, so you have it ready to revoke the key if that ever becomes needed. To actually revoke a key, the created revocation certificate needs to be merged with the key you're revoking. That's done by importing the revocation certificate using the --import command. Then the revoked key needs to be published โ€” which is best done by sending the key to a keyserver (command --send-key) and by exporting (--export) it to a file which is then send to frequent communication partners. Whole little pipeline, periodt.

  • --generate-designated-revocation name, --desig-revoke name โ€” generates a designated revocation certificate for a key. This lets a user (with the permission of the keyholder, obviously ๐Ÿซถ) revoke someone else's key. Trust falls but with cryptography.
  • --edit-key โ€” presents a menu which enables you to do most of the key management related tasks. It expects the specification of a key on the command line.

Okay so here's the menu, and it is loaded ๐ŸŽ€:

  • uid n โ€” toggle selection of user ID or photographic user ID with index n. Use * to select all and 0 to deselect all. Chef's kiss selection mechanics.
  • key n โ€” toggle selection of subkey with index n or key ID n. Use * to select all and 0 to deselect all.
  • sign โ€” make a signature on key of user name. If the key is not yet signed by the default user (or the users given with -u), the program displays the information of the key again, together with its fingerprint and asks whether it should be signed. This question is repeated for all users specified with -u. It's thorough! It's asking for consent! We love that.
  • lsign โ€” same as "sign" but the signature is marked as non-exportable and will therefore never be used by others. This may be used to make keys valid only in the local environment. Little private vibe ๐Ÿ’…
  • nrsign โ€” same as "sign" but the signature is marked as non-revocable and can therefore never be revoked. Like, never never. So think about it before you commit, bestie ๐Ÿ˜ญ
  • tsign โ€” make a trust signature. This is a signature that combines the notions of certification (like a regular signature), and trust (like the "trust" command). It's generally useful in distinct communities or groups to implement the concept of a Trusted Introducer. For more information please read the sections Trust Signature'' and Regular Expression'' in RFC-4880.
  • Note that "l" (for local / non-exportable), "nr" (for non-revocable, and "t" (for trust) may be freely mixed and prefixed to "sign" to create a signature of any type desired. Mix and match, it's giving build-your-own-signature โœจ
If the option --only-sign-text-ids is specified, then any non-text based user ids (e.g., photo IDs) will not be selected for signing.
  • delsig โ€” delete a signature. Note that it is not possible to retract a signature, once it has been send to the public (i.e. to a keyserver). In that case you better use revsig. Yeah. You can't un-send it. ๐Ÿ˜ฌ
  • revsig โ€” revoke a signature. For every signature which has been generated by one of the secret keys, GnuPG asks whether a revocation certificate should be generated.
  • check โ€” check the signatures on all selected user IDs. With the extra option selfsig only self-signatures are shown. Vibe check, literally ๐Ÿ”
  • adduid โ€” create an additional user ID.
  • addphoto โ€” create a photographic user ID. This will prompt for a JPEG file that will be embedded into the user ID. Note that a very large JPEG will make for a very large key. Also note that some programs will display your JPEG unchanged (GnuPG), and some programs will scale it to fit in a dialog box (PGP). So your selfie might get resized by the PGP girlies, just so you know ๐Ÿ™ˆ
  • showphoto โ€” display the selected photographic user ID.
  • deluid โ€” delete a user ID or photographic user ID. Note that it is not possible to retract a user id, once it has been send to the public (i.e. to a keyserver). In that case you better use revuid. Same deal as delsig: the internet remembers ๐Ÿ’€
  • revuid โ€” revoke a user ID or photographic user ID.
  • primary โ€” flag the current user id as the primary one, removes the primary user id flag from all other user ids and sets the timestamp of all affected self-signatures one second ahead. Note that setting a photo user ID as primary makes it primary over other photo user IDs, and setting a regular user ID as primary makes it primary over other regular user IDs. Two separate leaderboards, main character in each ๐ŸŒˆ
  • keyserver โ€” set a preferred keyserver for the specified user ID(s). This allows other users to know where you prefer they get your key from. See --keyserver-options honor-keyserver-url for more on how this works. Setting a value of "none" removes an existing preferred keyserver. It's basically your "find me here" link in bio ๐Ÿ’–
  • notation โ€” set a name=value notation for the specified user ID(s). See --cert-notation for more on how this works. Setting a value of "none" removes all notations, setting a notation prefixed with a minus sign (-) removes that notation, and setting a notation name (without the =value) prefixed with a minus sign removes all notations with that name. Tiny syntax, big power ๐Ÿงš
  • pref โ€” list preferences from the selected user ID. This shows the actual preferences, without including any implied preferences. Just the receipts, no extras.
  • showpref โ€” more verbose preferences listing for the selected user ID. This shows the preferences in effect by including the implied preferences of 3DES (cipher), SHA-1 (digest), and Uncompressed (compression) if they are not already included in the preference list. In addition, the preferred keyserver and signature notations (if any) are shown. It's pref but with the full unedited director's cut โœจ
  • setpref string โ€” set the list of user ID preferences to string for all (or just the selected) user IDs. Calling setpref with no arguments sets the preference list to the default (either built-in or set via --default-preference-list), and calling setpref with "none" as the argument sets an empty preference list. Use gpg --version to get a list of available algorithms.

Note that while you can change the preferences on an attribute user ID (aka "photo ID"), GnuPG does not select keys via attribute user IDs so these preferences will not be used by GnuPG. ๐Ÿซ  Note also that an unattended version of this command is available as --quick-update-pref.

When setting preferences, you should list the algorithms in the order which you'd like to see them used by someone else when encrypting a message to your key. If you don't include 3DES, it will be automatically added at the end. Note that there are many factors that go into choosing an algorithm (for example, your key may not be the only recipient), and so the remote OpenPGP application being used to send to you may or may not follow your exact chosen order for a given message. It will, however, only choose an algorithm that is present on the preference list of every recipient key. See also the INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS section below. Basically: you can rank them, but the group chat decides ๐Ÿ”ฅ

  • addkey โ€” add a subkey to this key.
  • addcardkey โ€” generate a subkey on a card and add it to this key. Card girlies rise ๐ŸŽ€
  • keytocard โ€” transfer the selected secret subkey (or the primary key if no subkey has been selected) to a smartcard. The secret key in the keyring will be replaced by a stub if the key could be stored successfully on the card and you use the save command later. Only certain key types may be transferred to the card. A sub menu allows you to select on what card to store the key.
โš ๏ธ Note that it is not possible to get that key back from the card โ€” if the card gets broken your secret key will be lost unless you have a backup somewhere. Like, actually lost. Back it up, bestie, please ๐Ÿ˜ญ
  • bkuptocard file โ€” restore the given file to a card. This command may be used to restore a backup key (as generated during card initialization) to a new card. In almost all cases this will be the encryption key. You should use this command only with the corresponding public key and make sure that the file given as argument is indeed the backup to restore. You should then select 2 to restore as encryption key. You will first be asked to enter the passphrase of the backup key and then for the Admin PIN of the card. Double-check the file first, fr fr โ€” wrong backup, wrong everything ๐ŸŒธ
  • keytotpm โ€” bestie, this one moves the selected secret subkey (or the primary key if you haven't selected a subkey) into TPM form. The secret key sitting in the keyring gets replaced by the TPM representation of that key, and here's the catch: that representation can only be read by the particular TPM that created it โ€” so your keyfile is now locked to the laptop containing the TPM ๐Ÿ˜ญ. Only certain key types may be transferred to the TPM (all TPM 2.0 systems are mandated to have the rsa2048 and nistp256 algorithms, but newer TPMs may have more). Also note that the key itself is not transferred into the TPM โ€” it's merely encrypted by the TPM in-place โ€” so if the keyfile is deleted, the key is gone forever. Once transferred to TPM representation, the key file can never be converted back to non-TPM form, and the key will die when the TPM does ๐Ÿ’€. So you should first have a backup on secure offline storage of the actual secret key file before conversion, fr fr. It's essential to use the physical system TPM that you have rw permission on the TPM resource manager device (/dev/tpmrm0). Usually this means you must be a member of the tss group.
  • delkey โ€” removes a subkey (secondary key). Heads up though: it is not possible to retract a subkey once it has been sent to the public (i.e. to a keyserver) ๐Ÿ™ˆ. In that case you better use revkey. Also note that this only deletes the public part of a key.
  • revkey โ€” revokes a subkey. Periodt.
  • expire โ€” changes the key or subkey expiration time. If a subkey is selected, the expiration time of this subkey will be changed. With no selection, the key expiration of the primary key is changed โœจ.
  • trust โ€” changes the owner trust value for the key. This updates the trust-db immediately and no save is required ๐Ÿซถ.
  • disable, enable โ€” disable or enable an entire key. A disabled key can not normally be used for encryption.
  • addrevoker โ€” adds a designated revoker to the key. This takes one optional argument: "sensitive". If a designated revoker is marked as sensitive, it will not be exported by default (see export-options).
  • addadsk โ€” adds an Additional Decryption Subkey. The user is asked to enter the fingerprint of another encryption subkey. Note that the exact fingerprint of another key's encryption subkey needs to be entered ๐Ÿ‘€ โ€” this is because commonly the primary key has no encryption capability. Use the option --with-subkey-fingerprint with a list command to display the subkey fingerprints.
  • passwd โ€” changes the passphrase of the secret key ๐Ÿ”.
  • toggle โ€” this is a dummy command which exists only for backward compatibility. It's giving legacy, ngl.
  • clean โ€” compacts (by removing all signatures except the selfsig) any user ID that is no longer usable (e.g. revoked, or expired). Then it removes any signatures that are not usable by the trust calculations. Specifically, this removes any signature that does not validate, any signature that is superseded by a later signature, revoked signatures, and signatures issued by keys that are not present on the keyring ๐Ÿงนโœจ.
  • minimize โ€” makes the key as small as possible. This removes all signatures from each user ID except for the most recent self-signature.
  • change-usage โ€” changes the usage flags (capabilities) of the primary key or of subkeys. These usage flags (e.g. Certify, Sign, Authenticate, Encrypt) are set during key creation. Sometimes it is useful to have the opportunity to change them (for example to add Authenticate) after they have been created. Please take care when doing this โ€” the allowed usage flags depend on the key algorithm โš ๏ธ.
  • cross-certify โ€” adds cross-certification signatures to signing subkeys that may not currently have them. Cross-certification signatures protect against a subtle attack against signing subkeys. See --require-cross-certification. All new keys generated have this signature by default, so this command is only useful to bring older keys up to date ๐Ÿ‘‘.
  • save โ€” saves all changes to the keyring and quits.
  • quit โ€” quits the program without updating the keyring.

Okay so the listing shows you the key with its secondary keys and all user IDs ๐Ÿ’…. The primary user ID is indicated by a dot, and selected keys or user IDs are indicated by an asterisk. The trust value is displayed with the primary key: "trust" is the assigned owner trust and "validity" is the calculated validity of the key. Validity values are also displayed for all user IDs. For possible values of trust, see: [trust-values].


  • --sign-key name โ€” signs a public key with your secret key ๐Ÿ”. This is a shortcut version of the subcommand "sign" from --edit-key.
  • --lsign-key name โ€” signs a public key with your secret key but marks it as non-exportable. This is a shortcut version of the subcommand "lsign" from --edit-key.
  • --quick-sign-key fpr [names], --quick-lsign-key fpr [names] โ€” directly sign a key from the passphrase without any further user interaction โšก. The fpr must be the verified primary fingerprint of a key in the local keyring. If no names are given, all useful user ids are signed; with given [names] only useful user ids matching one of these names are signed. By default, or if a name is prefixed with a '*', a case insensitive substring match is used. If a name is prefixed with a '=' a case sensitive exact match is done.

The command --quick-lsign-key marks the signatures as non-exportable. If such a non-exportable signature already exists the --quick-sign-key turns it into a exportable signature. If you need to update an existing signature, for example to add or change notation data, you need to use the option --force-sign-key.

This command uses reasonable defaults and thus does not provide the full flexibility of the "sign" subcommand from --edit-key. Its intended use is to help unattended key signing by utilizing a list of verified fingerprints ๐Ÿซถ.

  • --quick-add-uid user-id new-user-id โ€” this command adds a new user id to an existing key. In contrast to the interactive sub-command adduid of --edit-key the new-user-id is added verbatim with only leading and trailing white space removed, it is expected to be UTF-8 encoded, and no checks on its form are applied.
  • --quick-revoke-uid user-id user-id-to-revoke โ€” this command revokes a user ID on an existing key. It cannot be used to revoke the last user ID on key (some non-revoked user ID must remain), with revocation reason User ID is no longer valid. If you want to specify a different revocation reason, or to supply supplementary revocation text, you should use the interactive sub-command revuid of --edit-key.
  • --quick-revoke-sig fpr signing-fpr [names] โ€” this command revokes the key signatures made by signing-fpr from the key specified by the fingerprint fpr. With names given only the signatures on user ids of the key matching any of the given names are affected (see --quick-sign-key). If a revocation already exists a notice is printed instead of creating a new revocation; no error is returned in this case. Note that key signature revocations may be superseded by a newer key signature and in turn again revoked ๐Ÿ™ˆ.
  • --quick-set-primary-uid user-id primary-user-id โ€” this command sets or updates the primary user ID flag on an existing key. user-id specifies the key and primary-user-id the user ID which shall be flagged as the primary user ID. The primary user ID flag is removed from all other user ids and the timestamp of all affected self-signatures is set one second ahead โฑ๏ธ.
  • --quick-update-pref user-id โ€” this command updates the preference list of the key to the current default value (either built-in or set via --default-preference-list). This is the unattended version of using "setpref" in the --key-edit menu without giving a list. Note that you can show the preferences in a key listing by using --list-options show-pref or --list-options show-pref-verbose. You should also re-distribute updated keys to your peers ๐Ÿ’–.
  • --quick-set-ownertrust user-id value โ€” this command sets the ownertrust of a key and can also be used to set the disable flag of a key. This is the unattended version of using "trust", "disable", or "enable" in the --key-edit menu.
  • --change-passphrase user-id, --passwd user-id โ€” change the passphrase of the secret key belonging to the certificate specified as user-id. This is a shortcut for the sub-command passwd of the --edit-key menu. When using together with the option --dry-run this will not actually change the passphrase but check that the current passphrase is correct ๐Ÿ‘‘

โœจ OPTIONS โœจ

Okay so gpg features a bunch of options to control the exact behaviour and to change the default configuration ๐ŸŒˆ.

Long options can be put in an options file (default "~/.gnupg/gpg.conf"). Short option names will not work โ€” for example, "armor" is a valid option for the options file, while "a" is not ๐Ÿ™…. Do not write the 2 dashes, but simply the name of the option and any required arguments. Lines with a hash ('#') as the first non-white-space character are ignored. Commands may be put in this file too, but that is not generally useful as the command will execute automatically with every execution of gpg.

Please remember that option parsing stops as soon as a non-option is encountered, you can explicitly stop parsing by using the special option -- ๐Ÿ’….


๐ŸŒธ How to change the configuration ๐ŸŒธ

These options are used to change the configuration and most of them are usually found in the option file.

  • --default-key name โ€” this is your "this is literally who I am" signing key, bestie ๐Ÿ’…. Pass name as the key you want to sign with, and fr fr use a fingerprint or at least a long keyID for it โ€” shorter stuff is giving "I trust the vibes" and that's not the move. No --default-key at all? Then the default key is just the first key found in the secret keyring, which is chaotic but that's the rule. Heads up though: -u or --local-user overrides this option completely, no debate. You can give this option multiple times โ€” in that case, the last key for which a secret key is actually available gets used ๐Ÿ‘‘. And the sneaky part: if there's no secret key available for any of the values you specified, GnuPG will not emit an error message โ€” it just carries on as if you never gave this option at all ๐Ÿ˜ญ. Silent. Iconic, honestly, but silent.
  • --default-recipient name โ€” sets name as the default recipient when you didn't use --recipient, and it does not ask you whether it's a valid one. name must be non-empty, and yeah, a fingerprint for name is suggested here too โœจ.
  • --default-recipient-self โ€” uses your default key as the default recipient if --recipient isn't used, and again it doesn't ask if it's valid. The default key is the first one from the secret keyring, or whichever one you set with --default-key ๐ŸŽ€.
  • --no-default-recipient โ€” resets --default-recipient and --default-recipient-self back to nothing. Should not be used in an option file. Periodt.
  • -v, --verbose โ€” more info while processing, please and thank you ๐Ÿซถ. Use it twice and the input data gets listed in detail โ€” like, all the detail.
  • --no-verbose โ€” resets verbose level to 0. Should not be used in an option file.
  • -q, --quiet โ€” try to be as quiet as possible ๐Ÿคซ. Should not be used in an option file.
  • --batch
  • --no-batch โ€” batch mode, activated. Never ask, do not allow interactive commands โ€” none, zero, nope ๐Ÿ™ˆ. --no-batch disables it. But here's the thing: even with a filename given on the command line, gpg might still need to read from STDIN โ€” in particular if gpg figures out that the input is a detached signature and no data file has been specified. So if you do not want to feed data via STDIN, you should connect STDIN to /dev/null. That's the whole trick, no cap.

It is highly recommended to use this option along with the options --status-fd and --with-colons for any unattended use of gpg โ€” like, literally do this, it's the standard combo ๐Ÿ”ฅ. Should not be used in an option file.

  • --no-tty โ€” makes sure the TTY (terminal) is never used for any output ๐Ÿ’€. You need this in some cases because GnuPG sometimes prints warnings to the TTY even if --batch is used. Rude of it, but true.
  • --yes โ€” assumes "yes" on most questions. Should not be used in an option file.
  • --no โ€” assumes "no" on most questions. Should not be used in an option file.
  • --proc-all-sigs โ€” this option overrides the behaviour of the --batch option to stop signature verification at the first bad signatures. So instead of bailing early, it processes all the sigs ๐ŸŒˆ.

โœจ the list filter ๐Ÿ’–

  • --list-filter {select=expr} โ€” a list filter lets you output only certain keys during key listing commands ๐Ÿ”. For the available property names, go look at the description of --import-filter. iykyk.

๐ŸŽ€ --list-options โ€” the "how do I look" settings ๐ŸŽ€

  • --list-options parameters โ€” this is a space or comma delimited string that gives options used when listing keys and signatures โ€” that is, --list-keys, --check-signatures, --list-public-keys, --list-secret-keys, and the --edit-key functions ๐Ÿ’…. Any option can be prepended with a no- (after the two dashes) to give the opposite meaning. The options are:
    • show-photos โ€” causes --list-keys, --check-signatures, --list-public-keys, and --list-secret-keys to display any photo IDs attached to the key ๐Ÿ“ธ. Defaults to no. See also --photo-viewer. Does not work with --with-colons: see --attribute-fd for the appropriate way to get photo data for scripts and other frontends.
    • show-usage โ€” show usage information for keys and subkeys in the standard key listing. It's a list of letters indicating the allowed usage for a key (E=encryption, S=signing, C=certification, A=authentication) ๐Ÿ”‘. Defaults to yes.
    • show-ownertrust โ€” show the ownertrust value for keys, also in the standard key listing. Defaults to no.
    • show-policy-urls โ€” show policy URLs in the --check-signatures listings. Defaults to no.
    • show-notations
    • show-std-notations
    • show-user-notations โ€” show all, IETF standard, or user-defined signature notations in the --check-signatures listings. Defaults to no.
    • show-keyserver-urls โ€” show any preferred keyserver URL in the --check-signatures listings. Defaults to no.
    • show-uid-validity โ€” display the calculated validity of user IDs during key listings. Defaults to yes.
    • show-unusable-uids โ€” show revoked and expired user IDs in key listings. Defaults to no.
    • show-unusable-subkeys โ€” show revoked and expired subkeys in key listings. Defaults to no.
    • show-unusable-sigs โ€” show key signature made using weak or unsupported algorithms ๐Ÿ˜ฌ.
    • show-keyring โ€” display the keyring name at the head of key listings, so you can see which keyring a given key resides on. Defaults to no.
    • show-sig-expire โ€” show signature expiration dates (if any) during --check-signatures listings. Defaults to no.
    • show-sig-subpackets โ€” include signature subpackets in the key listing ๐Ÿ“ฆ. This option can take an optional argument list of the subpackets to list. If no argument is passed, list all subpackets. Defaults to no. This option is only meaningful when using --with-colons along with --check-signatures.
    • show-only-fpr-mbox โ€” for each user-id which has a valid mail address, print only the fingerprint followed by the mail address ๐Ÿ“ง.
    • sort-sigs โ€” with --list-sigs and --check-sigs, sort the signatures by keyID and creation time to make it easier to view the history of these signatures. The self-signature is also listed before other signatures โญ. Defaults to yes. This option has no effect in -with-colons mode.

๐Ÿฆ‹ --verify-options โ€” the vibes check for verification ๐Ÿฆ‹

  • --verify-options parameters โ€” a space or comma delimited string that gives options used when verifying signatures. Options can be prepended with a `no-' to give the opposite meaning. The options are:
    • show-photos โ€” display any photo IDs present on the key that issued the signature. Defaults to no. See also --photo-viewer.
    • show-policy-urls โ€” show policy URLs in the signature being verified. Defaults to yes.
    • show-notations
    • show-std-notations
    • show-user-notations โ€” show all, IETF standard, or user-defined signature notations in the signature being verified. Defaults to IETF standard.
    • show-keyserver-urls โ€” show any preferred keyserver URL in the signature being verified. Defaults to yes.
    • show-uid-validity โ€” display the calculated validity of the user IDs on the key that issued the signature. Defaults to yes.
    • show-unusable-uids โ€” show revoked and expired user IDs during signature verification. Defaults to no.
    • show-primary-uid-only โ€” show only the primary user ID during signature verification ๐Ÿ‘‘. That is, all the AKA lines as well as photo IDs are not shown with the signature verification status.

  • --enable-large-rsa
  • --disable-large-rsa โ€” with --generate-key and --batch, enable the creation of RSA secret keys as large as 8192 bit ๐Ÿ˜ณ. Note: 8192 bit is more than is generally recommended. These large keys don't significantly improve security, but they are more expensive to use, and their signatures and certifications are larger โ€” so it's giving "big for no reason" energy, honestly. This option is only available if the binary was build with large-secmem support.
  • --enable-dsa2
  • --disable-dsa2 โ€” enable hash truncation for all DSA keys, even for old DSA keys up to 1024 bit. This is also the default with --openpgp. Note that older versions of GnuPG also required this flag to allow the generation of DSA larger than 1024 bit ๐Ÿงš.
  • --photo-viewer string โ€” this is the command line that should be run to view a photo ID ๐Ÿ–ผ๏ธ. Here's the whole flag menu:
    • "%i" will be expanded to a filename containing the photo.
    • "%I" does the same, except the file will not be deleted once the viewer exits.
    • "%k" for the key ID.
    • "%K" for the long key ID.
    • "%f" for the key fingerprint.
    • "%t" for the extension of the image type (e.g. "jpg").
    • "%T" for the MIME type of the image (e.g. "image/jpeg").
    • "%v" for the single-character calculated validity of the image being viewed (e.g. "f").
    • "%V" for the calculated validity as a string (e.g. "full").
    • "%U" for a base32 encoded hash of the user ID.
    • "%%" for an actual percent sign.

If neither %i or %I are present, then the photo will be supplied to the viewer on standard input.

On Unix the default viewer is xloadimage -fork -quiet -title 'KeyID 0x%k' STDIN with a fallback to display -title 'KeyID 0x%k' %i and finally to xdg-open %i. On Windows !ShellExecute 400 %i is used; here the command is a meta command to use that API call followed by a wait time in milliseconds which is used to give the viewer time to read the temporary image file before gpg deletes it again ๐Ÿ’€. Note that if your image viewer program is not secure, then executing it from gpg does not make it secure โ€” that's just facts, bestie.

  • --exec-path string โ€” sets a list of directories to search for photo viewers ๐ŸŒธ. If not provided, photo viewers use the PATH environment variable.
  • --keyring file โ€” add file to the current list of keyrings ๐Ÿ”‘. If file begins with a tilde and a slash, these are replaced by the $HOME directory. If the filename does not contain a slash, it is assumed to be in the GnuPG home directory ("~/.gnupg" unless --homedir or $GNUPGHOME is used).

Note that this adds a keyring to the current list. If the intent is to use the specified keyring alone, use --keyring along with --no-default-keyring โ€” that combo is the actual move, fr fr.

If you've already hit --no-keyring, then congrats bestie, no keyrings get used at all. Zero. None. ๐Ÿ’…

And real talk โ€” if use-keyboxd is enabled in common.conf, then no keyrings are used at all and every single key is maintained by the keyboxd process in its own database instead. Different system, different vibe. ๐Ÿ—‚๏ธ

  • --primary-keyring file โ€” this is a variant of --keyring (yes, the manpage says "varian", we love a typo moment ๐Ÿ’€) and it designates file as the primary public keyring. Translation: any newly imported keys โ€” think --import or a keyserver --recv-from โ€” land in this keyring. It's the main character keyring. ๐Ÿ‘‘
  • --secret-keyring file โ€” obsolete and ignored, bestie, it literally does nothing. All your secret keys live in the private-keys-v1.d directory underneath the GnuPG home directory. That's just where they stay. ๐Ÿ 
  • --trustdb-name file โ€” use file instead of the default trustdb. Couple of rules: if file starts with a tilde and a slash, those get swapped out for the $HOME directory. And if the filename has no slash in it at all, it's assumed to be chilling in the GnuPG home directory โ€” which is ~/.gnupg as long as you're not using --homedir or $GNUPGHOME. ๐Ÿ“
  • --homedir dir โ€” sets the home directory to dir. Don't pass it and it defaults to ~/.gnupg. Two things though: it's only recognized when given on the command line, and it also overrides any home directory set through the environment variable GNUPGHOME โ€” or, on Windows systems, through the Registry entry HKCU\Software\GNU\GnuPG:HomeDir.

On Windows you can install GnuPG as a portable application, and in that case only this command line option is considered โ€” every other way of setting a home directory gets ignored entirely. ๐Ÿ™ˆ

  • --display-charset name โ€” sets the name of the native character set. What's it for? Converting informational strings, like user IDs, into the proper UTF-8 encoding. โœจ

Important clarification though: this has nothing to do with the character set of data you're encrypting or signing. GnuPG does not recode user-supplied data. Ever. If you skip this option, the default character set comes from your current locale, and a verbosity level of 3 will show you which set got chosen. Also, this option should not be used on Windows. ๐Ÿšซ

Valid values for name are:

  • iso-8859-1 โ€” this is the Latin 1 set.
  • iso-8859-2 โ€” the Latin 2 set.
  • iso-8859-15 โ€” currently just an alias for the Latin 1 set.
  • koi8-r โ€” the usual Russian set (RFC-1489).
  • utf-8 โ€” bypasses all translations and assumes the OS uses native UTF-8 encoding. No middleman energy. ๐Ÿฆ‹
  • --utf8-strings
  • --no-utf8-strings โ€” assume your command line arguments are given as UTF-8 strings. The default, --no-utf8-strings, assumes arguments are encoded in whatever character set --display-charset specifies. These options affect all following arguments, and both can be used multiple times. ๐Ÿซถ
Ngl, this option should not be used in an option file. And it has no effect on Windows โ€” over there the internally used UTF-8 encoding gets translated for console input and output, the command line arguments are expected as Unicode and translated to UTF-8. So if you're calling this program from another one, make sure you use the Unicode version of CreateProcess. ๐Ÿ˜ญ
  • --options file โ€” read options from file, and don't try reading them from the default options file in the homedir (peep --homedir). This option is ignored if you use it inside an options file. Inception denied. ๐Ÿ™…
  • --no-options โ€” a shortcut for --options /dev/null. It's detected before any attempt to open an option file is even made. Bonus: using this also prevents the creation of a ~/.gnupg homedir. Nothing gets born. ๐Ÿ’€
  • -z n
  • --compress-level n
  • --bzip2-compress-level n
  • --no-compress โ€” sets the compression level to n for the ZIP and ZLIB compression algorithms. Default is to use zlib's own default compression level (normally 6). --bzip2-compress-level sets the level for the BZIP2 compression algorithm instead (defaulting to 6 as well). Why is it a separate option from --compress-level? Because BZIP2 eats a significant amount of memory for each additional compression level. ๐Ÿง ๐Ÿ’ฅ

Option -z sets both. A value of 0 for n disables compression. A value of -1 forces compression using the default level. And --no-compress is identical to -z0.

Here's the tea: except for the --store command, compression is always used unless gpg detects that the input is already compressed. To inhibit compression use -z0 or --no-compress; to force compression use -z-1, or use option z with a compression level other than the default as indicated by -1. And note โ€” this overriding of the default detection works only with z, not with the long variant of this option. ๐ŸŽ€

  • --bzip2-decompress-lowmem โ€” uses a different decompression method for BZIP2 compressed files. This alternate method uses a bit more than half the memory, but it also runs at half the speed. Super useful under extreme low memory circumstances, especially when the file was originally compressed at a high --bzip2-compress-level. Slow and steady, bestie. ๐Ÿข
  • --mangle-dos-filenames
  • --no-mangle-dos-filenames โ€” older versions of Windows can't handle filenames with more than one dot in them. --mangle-dos-filenames makes GnuPG replace (rather than add to) the extension of an output filename, avoiding the whole problem. It's off by default and does absolutely nothing on non-Windows platforms. ๐Ÿ™ˆ
  • --ask-cert-level
  • --no-ask-cert-level โ€” when you're making a key signature, this prompts you for a certification level. Don't specify it and the certification level used is set via --default-cert-level (go read that entry for the specific levels and how they're used). --no-ask-cert-level disables it. And the default for this option? No. ๐Ÿ’…
  • --default-cert-level n โ€” the default to use for the check level when signing a key. Let's break down the levels, because this is literally the whole personality of the option:
    • 0 โ€” you make no particular claim as to how carefully you verified the key. Vibes only. ๐Ÿ“
    • 1 โ€” you believe the key is owned by the person who claims to own it, but you could not, or did not, verify the key at all. Handy for a "persona" verification, where you sign the key of a pseudonymous user. ๐ŸŽญ
    • 2 โ€” you did casual verification of the key. For example, this could mean you verified the key fingerprint and checked the user ID on the key against a photo ID. ๐Ÿชช
    • 3 โ€” you did extensive verification of the key. For example, this could mean you verified the key fingerprint with the owner of the key in person, and you checked โ€” by means of a hard to forge document with a photo ID, such as a passport โ€” that the name of the key owner matches the name in the user ID on the key, and finally that you verified (by exchange of email) that the email address on the key belongs to the key owner. Full detective mode. ๐Ÿ•ต๏ธโ€โ™€๏ธ
Ok but real talk: the examples given above for levels 2 and 3 are just that โ€” examples. In the end it's up to you to decide what "casual" and "extensive" actually mean to you. No one's grading this. ๐Ÿ’–

This option defaults to 0 (no particular claim).

  • --min-cert-level โ€” when building the trust database, treat any signatures with a certification level below this as invalid. Defaults to 2, which disregards level 1 signatures. But heads up: level 0 "no particular claim" signatures are always accepted, no matter what. ๐Ÿ‘‘
  • --trusted-key long key ID or fingerprint โ€” assume the specified key (which should be given as a fingerprint) is as trustworthy as one of your own secret keys. This is the move if you don't want to keep your secret keys โ€” or even one of them โ€” online, but you still want to be able to check the validity of a given recipient's or signator's key. ๐Ÿซถ

If the given key isn't locally available but an LDAP keyserver is configured, the missing key gets imported from that server. And the value "none" is explicitly allowed, so you can distinguish between using any trusted-key option and not using this option at all (say, because of --no-options). ๐Ÿ˜Œ

  • --add-desig-revoker [sensitive:]fingerprint โ€” adds the key specified by fingerprint as a designated revoker to newly created keys. If the fingerprint is prefixed with the keyword sensitive: that info is normally not exported with the key. ๐Ÿคซ

You can give this option several times to add more than one designated revoker. If you use the keyword clear instead of a fingerprint, all previously given fingerprints get discarded. Designated revokers are marked on the key as non-revocable. And note: a designated revoker specified using a parameter file will also be added to the key. ๐ŸŽ€

  • --default-new-key-adsk fingerprint โ€” adds the subkey specified by fingerprint as an Additional Decryption Subkey (ADSK) to newly created keys. You can give this option several times to add more than one ADSK. It's also possible to give several fingerprints delimited by space or comma as the value to this option. ๐Ÿฆ‹

If the keyword clear is used instead of a fingerprint, all previously specified fingerprints are discarded โ€” which is useful for overriding options given in a config file. The fingerprint is expected to specify a subkey, and it does not need an exclamation mark as a suffix; it must be given in compact format (40 or 64 hex-digits without any spaces). No spaces, bestie, we're serious. ๐Ÿ’…

  • --trust-model {pgp|classic|tofu|tofu+pgp|direct|always|auto} โ€” sets what trust model GnuPG should follow. The models are:
    • pgp โ€” this is the Web of Trust combined with trust signatures as used in PGP 5.x and later. It's the default trust model when creating a new trust database. ๐Ÿ‘‘
    • classic โ€” this is the standard Web of Trust as introduced by PGP 2.
    • tofu

okay so TOFU stands for Trust On First Use, and heads up: this whole trust model is experimental. The vibe is โ€” the first time a key is seen, it's memorized (like the group chat never forgetting a name ๐Ÿ‘€). If later another key with a user id carrying the same email address shows up, both keys get marked as suspect ๐Ÿšฉ. And then the next time either of them is used, a warning pops up describing the conflict, explaining why it might have happened โ€” either the user generated a new key and failed to cross sign the old and new keys, the key is a forgery, or a man-in-the-middle attack is being attempted โ€” and then you get prompted to manually confirm the validity of the key in question. so like, pay attention bestie ๐Ÿ’…

Because a potential attacker is able to control the email address and thereby circumvent the conflict detection algorithm by using an email address that is similar in appearance to a trusted email address, whenever a message is verified, statistics about the number of messages signed with the key are shown. That way a user can easily identify attacks using fake keys for regular correspondents. cute little receipt trail, love that for us ๐Ÿงพโœจ

When compared with the Web of Trust, TOFU offers significantly weaker security guarantees โ€” be so for real about that. In particular, TOFU only helps ensure consistency (that is, that the binding between a key and email address doesn't change). A major advantage of TOFU is that it requires little maintenance to use correctly. To use the web of trust properly, you need to actively sign keys and mark users as trusted introducers. That is a time-consuming process, and anecdotal evidence suggests that even security-conscious users rarely take the time to do this thoroughly and instead rely on an ad-hoc TOFU process. (they're just like me fr ๐Ÿ˜ญ)

In the TOFU model, policies are associated with bindings between keys and email addresses (which are extracted from user ids and normalized). There are five policies, which can be set manually using the --tofu-policy option. The default policy can be set using the --tofu-default-policy option.

The TOFU policies are: auto, good, unknown, bad and ask.

  • The auto policy is used by default (unless overridden by --tofu-default-policy) and marks a binding as marginally trusted.
  • The good, unknown and bad policies mark a binding as fully trusted, as having unknown trust, or as having trust never, respectively.
  • The unknown policy is useful for just using TOFU to detect conflicts, but to never assign positive trust to a binding.
  • The final policy, ask, prompts the user to indicate the binding's trust. If batch mode is enabled (or input is inappropriate in the context), then the user is not prompted and the undefined trust level is returned.

๐ŸŒˆ tofu+pgp

This experimental trust model combines TOFU with the Web of Trust. How? By computing the trust level for each model and then taking the maximum trust level, where the trust levels are ordered like this:

unknown < undefined < marginal < fully < ultimate < expired < never

By setting --tofu-default-policy=unknown, this model can be used to implement the web of trust with TOFU's conflict detection algorithm, but without its assignment of positive trust values โ€” which some security-conscious users don't like. valid honestly ๐Ÿซถ

๐ŸŽ€ direct

Key validity is set directly by the user and not calculated via the Web of Trust. This model is solely based on the key and does not distinguish user IDs. Note that when changing to another trust model, the trust values assigned to a key are transformed into ownertrust values, which also indicate how you trust the owner of the key to sign other keys. (it's giving "I said what I said".)

๐Ÿ‘‘ always

Skip key validation and assume that used keys are always fully valid. You generally won't use this unless you are using some external validation scheme. This option also suppresses the "[uncertain]" tag printed with signature checks when there is no evidence that the user ID is bound to the key. Note that this trust model still does not allow the use of expired, revoked, or disabled keys โ€” no exceptions, bestie, expired is expired ๐Ÿ’€

โญ auto

Select the trust model depending on whatever the internal trust database says. This is the default model if such a database already exists. Note that a tofu trust model is not considered here and must be enabled explicitly. (it will NOT read your mind ๐Ÿ™ˆ)


  • --always-trust โ€” Identical to --trust-model always.
  • --assert-signer fpr_or_file โ€” This option checks whether at least one valid signature on a file has been made with the specified key. The key is either specified as a fingerprint or a file listing fingerprints. The fingerprint must be given or listed in compact format (no colons or spaces in between). This option can be given multiple times, and each fingerprint is checked against the signing key as well as the corresponding primary key. If fpr_or_file specifies a file, empty lines are ignored as well as all lines starting with a hash sign. With this option gpg is guaranteed to return with an exit code of 0 if and only if a signature has been encountered, is valid, and the key matches one of the fingerprints given by this option. no notes, that's a clean guarantee โœจ
  • --assert-pubkey-algo algolist โ€” During data signature verification this option checks whether the used public key algorithm matches the algorithms given by algolist. This option can be given multiple times to concatenate more algorithms to the list; the delimiter of the list are either commas or spaces.

The algorithm names given in the list may either be verbatim names like "ed25519" with an optional leading single equal sign, or being prefixed with >, >=, <=, or <. That prefix operator is applied to the number part of the algorithm name; for example 2048 in "rsa2048" or 384 in "brainpoolP384r1". If the leading non-digits in the name matches, the prefix operator is used to compare the number part, and a trailing suffix is ignored in this case. For example an algorithm list ">rsa3000, >=brainpool384r1, =ed25519" allows RSA signatures with more than 3000 bits, Brainpool curves 384 and 512, and the ed25519 algorithm. the way this eats ๐Ÿ”ฅ

With this option gpg (and also gpgv) is guaranteed to return with an exit code of 0 if and only if all valid signatures on data are made using a matching algorithm from the given list.

  • --auto-key-locate mechanisms, --no-auto-key-locate โ€” GnuPG can automatically locate and retrieve keys as needed using this option. This happens when encrypting to an email address (in the "user@example.com" form), and there are no "user@example.com" keys on the local keyring. This option takes any number of the mechanisms listed below, in the order they are to be tried. Instead of listing the mechanisms as comma delimited arguments, the option may also be given several times to add more mechanisms. The option --no-auto-key-locate or the mechanism "clear" resets the list. The default is "local,wkd".
    • cert โ€” Locate a key using DNS CERT, as specified in RFC-4398.
    • dane โ€” Locate a key using DANE, as specified in draft-ietf-dane-openpgpkey-05.txt.
    • wkd โ€” Locate a key using the Web Key Directory protocol.
    • ldap โ€” Locate the key using the configured LDAP servers. This method is similar to the keyserver mechanism but always uses only LDAP servers.
    • ntds โ€” Locate the key using the Active Directory (Windows only). This method also allows one to search by fingerprint using the command --locate-external-key. Note that this mechanism is actually a shortcut for the mechanism โ€˜ldapโ€™ using only "ldap:///" as the keyserver.
    • keyserver โ€” Locate a key using a keyserver. This method also allows one to search by fingerprint using the command --locate-external-key if any of the configured keyservers is an LDAP server.
    • keyserver-URL โ€” In addition, a keyserver URL as used in the dirmngr configuration may be used here to query that particular keyserver. This method also allows one to search by fingerprint using the command --locate-external-key if the URL specifies an LDAP server.
    • local โ€” Locate the key using the local keyrings. This mechanism allows the user to select the order a local key lookup is done. Thus using โ€˜--auto-key-locate localโ€™ is identical to --no-auto-key-locate.
    • nodefault โ€” This flag disables the standard local key lookup, done before any of the mechanisms defined by the --auto-key-locate are tried. The position of this mechanism in the list does not matter. It is not required if local is also used.
    • clear โ€” Clear all defined mechanisms. This is useful to override mechanisms given in a config file. Note that a nodefault in mechanisms will also be cleared unless it is given after the clear. sneaky little ordering detail, iykyk ๐Ÿ˜Œ
  • --auto-key-import, --no-auto-key-import โ€” This is an offline mechanism to get a missing key for signature verification and for later encryption to this key. If this option is enabled and a signature includes an embedded key, that key is used to verify the signature and on verification success the key is imported. The default is --no-auto-key-import.

On the sender (signing) site the option --include-key-block needs to be used to put the public part of the signing key as โ€œKey Block subpacketโ€ into the signature. ๐Ÿฆ‹

  • --auto-key-retrieve, --no-auto-key-retrieve โ€” okay so this is the "go get the key for me" switch ๐Ÿซถ. It enables or disables automatically retrieving keys from a keyserver when you're verifying signatures made by keys that are not on your local keyring. The default is --no-auto-key-retrieve, so it's off unless you turn it on.

The order of methods it tries to look up the key is, literally:

  1. If the option --auto-key-import is set and the signature includes an embedded key, that key is used to verify the signature and on verification success that key is imported.
  2. If a preferred keyserver is specified in the signature and the option honor-keyserver-url is active (which is not the default), that keyserver is tried. Note that the creator of the signature uses the option --sig-keyserver-url to specify the preferred keyserver for data signatures.
  3. If the signature has the Signer's UID set (e.g. using --sender while creating the signature) a Web Key Directory (WKD) lookup is done. This is the default configuration but can be disabled by removing WKD from the auto-key-locate list or by using the option --disable-signer-uid.
  4. If any keyserver is configured and the Issuer Fingerprint is part of the signature (since GnuPG 2.1.16), the configured keyservers are tried.
Heads up bestie ๐Ÿ˜ญ this option makes a "web bug" like behavior possible. Keyserver or Web Key Directory operators can see which keys you request, so by sending you a message signed by a brand new key (which you naturally will not have on your local keyring), the operator can tell both your IP address and the time when you verified the signature. Kinda creepy, no cap.
  • --keyid-format {none|short|0xshort|long|0xlong} โ€” controls how key IDs get displayed โœจ. "none" does not show the key ID at all but shows the fingerprint in a separate line. "short" is the traditional 8-character key ID. "long" is the more accurate (but less convenient) 16-character key ID. Add an "0x" to either to include an "0x" at the beginning of the key ID, as in 0x99242560. Note that this option is ignored if the option --with-colons is used.
  • --keyserver name โ€” okay so this one is deprecated, please use the --keyserver in dirmngr.conf instead ๐Ÿ™ˆ.

It uses name as your keyserver. This is the server that --receive-keys, --send-keys, and --search-keys will communicate with to receive keys from, send keys to, and search for keys on. The format of the name is a URI: scheme:[//]keyservername[:port]. The scheme is the type of keyserver: "hkp"/"hkps" for the HTTP (or compatible) keyservers or "ldap"/"ldaps" for the LDAP keyservers. Note that your particular installation of GnuPG may have other keyserver types available as well. Keyserver schemes are case-insensitive.

Most keyservers synchronize with each other, so there is generally no need to send keys to more than one server. The keyserver hkp://keys.gnupg.net uses round robin DNS to give a different keyserver each time you use it.

  • --keyserver-options {name=value} โ€” this is a space or comma delimited string that gives options for the keyserver ๐Ÿ’…. Options can be prefixed with a no- to give the opposite meaning. Valid import-options or export-options may be used here as well to apply to importing (--recv-key) or exporting (--send-key) a key from a keyserver. While not all options are available for all keyserver types, some common options are:
    • include-revoked โ€” when searching for a key with --search-keys, include keys that are marked on the keyserver as revoked. Note that not all keyservers differentiate between revoked and unrevoked keys, and for such keyservers this option is meaningless. Note also that most keyservers do not have cryptographic verification of key revocations, and so turning this option off may result in skipping keys that are incorrectly marked as revoked.
    • include-disabled โ€” when searching for a key with --search-keys, include keys that are marked on the keyserver as disabled. Note that this option is not used with HKP keyservers.
    • auto-key-retrieve โ€” this is an obsolete alias for the option auto-key-retrieve. Please do not use it; it will be removed in future versions..
    • honor-keyserver-url โ€” when using --refresh-keys, if the key in question has a preferred keyserver URL, then use that preferred keyserver to refresh the key from. In addition, if auto-key-retrieve is set, and the signature being verified has a preferred keyserver URL, then use that preferred keyserver to fetch the key from. Note that this option introduces a "web bug": the creator of the key can see when the key is refreshed. Thus this option is not enabled by default.
    • include-subkeys โ€” when receiving a key, include subkeys as potential targets. Note that this option is not used with HKP keyservers, as they do not support retrieving keys by subkey id.
    • only-pubkeys โ€” do now allow to import secret keys.
    • timeout, http-proxy=value, verbose, debug, check-cert, ca-cert-file โ€” these options have no more function since GnuPG 2.1 ๐Ÿ”ฅ. Use the dirmngr configuration options instead.

The default list of options is: <pink>"self-sigs-only, repair-keys, repair-pks-subkey-bug, export-attributes"</pink>. However, if the actual used source is an LDAP server "no-self-sigs-only"is assumed unless"self-sigs-only"` has been explicitly configured.

  • --completes-needed n โ€” number of completely trusted users to introduce a new key signer (defaults to 1).
  • --marginals-needed n โ€” number of marginally trusted users to introduce a new key signer (defaults to 3).
  • --tofu-default-policy {auto|good|unknown|bad|ask} โ€” the default TOFU policy (defaults to auto) ๐Ÿซถ. For more information about the meaning of this option, see: [trust-model-tofu].
  • --max-cert-depth n โ€” maximum depth of a certification chain (default is 5).
  • --no-sig-cache โ€” do not cache the verification status of key signatures. Caching gives a much better performance in key listings, lowkey iconic. However, if you suspect that your public keyring is not safe against write modifications, you can use this option to disable the caching. It probably does not make sense to disable it because all kind of damage can be done if someone else has write access to your public keyring ๐Ÿ’€.
  • --auto-check-trustdb, --no-auto-check-trustdb โ€” if GnuPG feels that its information about the Web of Trust has to be updated, it automatically runs the --check-trustdb command internally. This may be a time consuming process ๐Ÿ˜ญ. --no-auto-check-trustdb disables this option.
  • --use-agent, --no-use-agent โ€” this is a dummy option. gpg always requires the agent. That's it, that's the whole vibe ๐Ÿ™ˆ.
  • --gpg-agent-info โ€” this is a dummy option. It has no effect when used with gpg.
  • --agent-program file โ€” specify an agent program to be used for secret key operations. The default value is determined by running gpgconf with the option --list-dirs. Note that the pipe symbol (|) is used for a regression test suite hack and may thus not be used in the file name.
  • --dirmngr-program file โ€” specify a dirmngr program to be used for keyserver access. The default value is /usr/bin/dirmngr.
  • --disable-dirmngr โ€” entirely disable the use of the Dirmngr โœจ.
  • --no-autostart โ€” do not start the gpg-agent or the dirmngr if it has not yet been started and its service is required. This option is mostly useful on machines where the connection to gpg-agent has been redirected to another machine. If dirmngr is required on the remote machine, it may be started manually using gpgconf --launch dirmngr.
  • --lock-once โ€” lock the databases the first time a lock is requested and do not release the lock until the process terminates.
  • --lock-multiple โ€” release the locks every time a lock is no longer needed. Use this to override a previous --lock-once from a config file.
  • --lock-never โ€” disable locking entirely. This option should be used only in very special environments, where it can be assured that only one process is accessing those files. A bootable floppy with a stand-alone encryption system will probably use this. Improper usage of this option may lead to data and key corruption โ€” no cap, be careful ๐Ÿซถ.
  • --exit-on-status-write-error โ€” this option will cause write errors on the status FD to immediately terminate the process. That should in fact be the default but it never worked this way and thus we need an option to enable this, so that the change won't break applications which close their end of a status fd connected pipe too early. Using this option along with --enable-progress-filter may be used to cleanly cancel long running gpg operations.
  • --limit-card-insert-tries n โ€” with n greater than 0 the number of prompts asking to insert a smartcard gets limited to N-1. Thus with a value of 1 gpg won't at all ask to insert a card if none has been inserted at startup. This option is useful in the configuration file in case an application does not know about the smartcard support and waits ad infinitum for an inserted card ๐Ÿ˜ญ.
  • --no-random-seed-file โ€” GnuPG uses a file to store its internal random pool over invocations. This makes random generation faster; however sometimes write operations are not desired. This option can be used to achieve that with the cost of slower random generation.
  • --no-greeting โ€” suppress the initial copyright message. Bye bye lil banner ๐Ÿ’….
  • --no-secmem-warning โ€” suppress the warning about "using insecure memory".
  • --no-permission-warning โ€” bestie, this one mutes the warning about unsafe file and home directory (--homedir) permissions. But listen โ€” GnuPG's permission checks are not meant to be authoritative, they literally just flag certain common permission problems, that's it. So do not assume that no warning = your system is secure. It isn't a vibe check on your whole setup, okay? ๐Ÿ’…

Also super important: the warning for unsafe --homedir permissions cannot be suppressed in the gpg.conf file, because that would let an attacker drop an unsafe gpg.conf in place and use that very file to silence warnings about itself. Rude. So the --homedir permissions warning can only ever be suppressed on the command line. Periodt.

  • --require-secmem, --no-require-secmem โ€” refuse to run at all if GnuPG can't get secure memory. Defaults to no, meaning it runs anyway but gives you a warning. ๐Ÿ™ˆ
  • --require-cross-certification, --no-require-cross-certification โ€” when verifying a signature made from a subkey, make sure the cross certification "back signature" on the subkey is present and valid. This protects against a subtle attack against subkeys that can sign. For gpg it defaults to --require-cross-certification. ๐Ÿ”ฅ
  • --expert, --no-expert โ€” lets the user do certain nonsensical or "silly" things, like signing an expired or revoked key, or certain potentially incompatible things like generating unusual key types. It also disables certain warning messages about potentially incompatible actions. As the name implies, this option is for experts only โ€” if you don't fully understand the implications of what it allows you to do, leave it off, no cap. --no-expert disables this option. ๐Ÿ’€

  • --recipient name, -r โ€” encrypt for user id name. If this option or --hidden-recipient isn't specified, GnuPG asks for the user-id โ€” unless --default-recipient is given. ๐Ÿ’Œ
  • --hidden-recipient name, -R โ€” encrypt for user ID name, but hide the key ID of this user's key. This option helps hide the receiver of the message and is a limited countermeasure against traffic analysis. If this option or --recipient isn't specified, GnuPG asks for the user ID unless --default-recipient is given. ๐Ÿ•ต๏ธโ€โ™€๏ธ
  • --recipient-file file, -f โ€” similar to --recipient except it encrypts to a key stored in the given file. file must be the name of a file containing exactly one key. gpg assumes that the key in this file is fully valid.
  • --hidden-recipient-file file, -F โ€” similar to --hidden-recipient except it encrypts to a key stored in the given file. file must be the name of a file containing exactly one key. gpg assumes that the key in this file is fully valid. โœจ
  • --encrypt-to name โ€” same as --recipient but this one is intended for use in the options file and may be used with your own user-id as an "encrypt-to-self". It's suggested you use a fingerprint or at least a long keyID for name. These keys are only used when there are other recipients given either by use of --recipient or by the asked user id. No trust checking is performed for these user ids, and even disabled keys can be used. ๐Ÿ˜ณ
  • --hidden-encrypt-to name โ€” same as --hidden-recipient but intended for use in the options file, and may be used with your own user-id as a hidden "encrypt-to-self". Again, use a fingerprint or at least a long keyID for name. These keys are only used when there are other recipients given either by use of --recipient or by the asked user id. No trust checking for these user ids, and even disabled keys can be used.
  • --no-encrypt-to โ€” disables the use of all --encrypt-to and --hidden-encrypt-to keys. ๐Ÿšซ
  • --group {name=value} โ€” sets up a named group, which is similar to aliases in email programs. Any time the group name is a recipient (-r or --recipient), it gets expanded to the values specified. Multiple groups with the same name are automatically merged into a single group. ๐Ÿซถ

The values are key IDs or fingerprints, but any key description is accepted. Note that a value with spaces in it will be treated as two different values. Note also there's only one level of expansion โ€” you cannot make a group that points to another group. When used from the command line, it may be necessary to quote the argument to this option so the shell doesn't treat it as multiple arguments.

  • --ungroup name โ€” remove a given entry from the --group list.
  • --no-groups โ€” remove all entries from the --group list.
  • --local-user name, -u โ€” use name as the key to sign with. Note that this option overrides --default-key. โœ๏ธ
  • --sender mbox โ€” this option has two purposes. mbox must either be a complete user ID containing a proper mail address, or just a plain mail address. The option can be given multiple times.

When creating a signature, this option tells gpg the signing key's user id used to make the signature and embeds that user ID into the created signature (using OpenPGP's ``Signer's User ID'' subpacket). If the option is given multiple times, a suitable user ID is picked. However, if the signing key was specified directly by using a mail address (i.e. not by using a fingerprint or key ID), this option is used and the mail address is embedded in the created signature.

When verifying a signature, mbox is used to restrict the information printed by the TOFU code to matching user IDs. If the option is used and the signature contains a ``Signer's User ID'' subpacket, that information is also used to restrict the printed information. Note that GnuPG considers only the mail address part of a User ID.

If this option or the said subpacket is available, the TRUST lines as printed by option status-fd correspond to the corresponding User ID; if no User ID is known, the TRUST lines are computed directly on the key and don't give any information about the User ID. In the latter case it's highly recommended to scripts and other frontends to evaluate the VALIDSIG line, retrieve the key, and print all User IDs along with their validity (trust) information. ๐Ÿ“œ

  • --try-secret-key name โ€” for hidden recipients GPG needs to know the keys to use for trial decryption. The key set with --default-key is always tried first, but this is often not sufficient. This option lets you set more keys to be used for trial decryption. Although any valid user-id specification may be used for name, it makes sense to use at least the long keyid to avoid ambiguities. Note that gpg-agent might pop up a pinentry for a lot of keys to do the trial decryption ๐Ÿ˜ญ โ€” if you want to stop all further trial decryption, you may use the close-window button instead of the cancel button. (iykyk)
  • --try-all-secrets โ€” don't look at the key ID as stored in the message, just try all secret keys in turn to find the right decryption key. This option forces the behaviour as used by anonymous recipients (created by using --throw-keyids or --hidden-recipient) and might come in handy when an encrypted message contains a bogus key ID. ๐Ÿ”
  • --skip-hidden-recipients, --no-skip-hidden-recipients โ€” during decryption, skip all anonymous recipients. This helps when people use the hidden recipients feature to hide their own encrypt-to key from others. If you have many secret keys, this can be a major annoyance, because all keys get tried in turn to decrypt something that wasn't really intended for them. The drawback? It's currently not possible to decrypt a message which includes real anonymous recipients. ๐Ÿฅฒ

๐Ÿ“ฅ Input and Output ๐Ÿ“ค

  • --armor, -a โ€” create ASCII armored output. The default is to create the binary OpenPGP format. ๐ŸŽ€
  • --no-armor โ€” assume the input data is not in ASCII armored format.
  • --output file, -o file โ€” write output to file. To write to stdout, use - as the filename. ๐Ÿ“
  • --max-output n โ€” sets a limit on the number of bytes that will be generated when processing a file. Since OpenPGP supports various levels of compression, it's possible that the plaintext of a given message may be significantly larger than the original OpenPGP message. While GnuPG works properly with such messages, there's often a desire to set a maximum file size that'll be generated before processing is forced to stop by the OS limits. Defaults to 0, which means "no limit". ๐Ÿ”ฅ
  • --chunk-size n โ€” the AEAD encryption mode encrypts the data in chunks so a receiving side can check for transmission errors or tampering at the end of each chunk and doesn't need to delay this until all data has been received. The used chunk size is 2^n byte. The lowest allowed value for n is 6 (64 byte) and the largest is the default of 22, which creates chunks not larger than 4 MiB. ๐Ÿงฑ
  • --input-size-hint n โ€” tells GPG the size of the input data in bytes. n must be a positive base-10 number. This option is only useful if the input isn't taken from a file. GPG may use this hint to optimize its buffer allocation strategy. It's also used by the --status-fd line PROGRESS'' to provide a value for total'' if that isn't available by other means. ๐Ÿ“
  • --key-origin string[,url] โ€” gpg can track the origin of a key. Certain origins are implicitly known (e.g. keyserver, web key directory) and set. For a standard import, the origin of the keys imported can be set with this option. To list the possible values, use "help" for string. Some origins can store an optional url argument โ€” that URL can be appended to string after a comma. ๐ŸŒ
  • --import-options parameters โ€” this is a space or comma delimited string that gives options for importing keys. Options can be prepended with a no- to give the opposite meaning. The options are:
  • import-local-sigs โ€” lets key signatures that are marked as "local" come on in. Ngl this is not generally useful unless you're running a shared keyring scheme. Defaults to no. ๐Ÿ’…
  • keep-ownertrust โ€” okay so normally, if a key gets imported, any ownertrust values that still exist for it get cleared. That's usually exactly what you want, so a formerly deleted key doesn't automatically gain ownertrust values just because it came back through an import. But sometimes you do need to re-import a trusted set of keys and keep the ownertrust values you already handed out โ€” that's what this option is for. ๐Ÿซถ
  • repair-pks-subkey-bug โ€” during import, try to repair the damage caused by the PKS keyserver bug (pre version 0.9.6) that mangles keys with multiple subkeys. Heads up tho: this cannot completely repair the damaged key, because some crucial data was already removed by the keyserver โ€” it does at least give you back one subkey. Defaults to no for regular --import and to yes for keyserver --receive-keys. ๐Ÿ˜ญ
  • import-show, show-only โ€” shows you a listing of the key as it's imported, right before it gets stored. You can combine this with --dry-run to only look at keys without touching anything; show-only is a shortcut for that exact combo. The command --show-keys is another shortcut for it. Note that suffixes like '#' for "sec" and "sbb" lines may or may not be printed. ๐Ÿ‘€
  • import-export โ€” runs the entire import code path, but instead of storing the key into the local keyring it writes it to the output. The export option export-dane affects the output. Handy for stuff like removing all the invalid parts from a key without ever needing to store it. โœจ
  • merge-only โ€” during import, key updates to existing keys are allowed, but no new keys may be imported. Defaults to no.
  • import-clean โ€” after import, compact any user IDs from the new key that aren't usable (compact = remove all signatures except the self-signature). Then remove any signatures from the new key that aren't usable โ€” and yeah, that includes signatures issued by keys that aren't present on the keyring. Same thing as running the --edit-key command "clean" after import. Defaults to no. ๐Ÿงน
  • self-sigs-only โ€” accept only self-signatures while importing a key; all other key signatures get skipped at an early import stage. Pair it with keyserver-options to mitigate attempts to flood a key with bogus signatures from a keyserver. The drawback (and it's a real one) is that all the other valid key signatures, as required by the Web of Trust, also don't get imported. Also note: when you use this together with import-clean, it suppresses the final clean step after merging the imported key into the existing key. โš ๏ธ
  • ignore-attributes โ€” ignore all attribute user IDs (photo IDs) and their signatures while importing a key. ๐Ÿ™ˆ
  • repair-keys โ€” after import, fix various problems with the keys โ€” for example it reorders signatures and strips duplicate signatures. Defaults to yes.
  • bulk-import โ€” when used, the keyboxd (option use-keyboxd in common.conf) does the import within a single transaction. โšก
  • import-minimal โ€” import the smallest key possible: removes all signatures except the most recent self-signature on each user ID. Same as running the --edit-key command "minimize" after import. Defaults to no.
  • restore, import-restore โ€” import in key restore mode. This imports all the data that's usually skipped during import, including all GnuPG specific data. All other contradicting options are overridden. ๐Ÿ‘‘

  • --import-filter {name=expr}
  • --export-filter {name=expr}

These define an import/export filter that gets applied to the imported/exported keyblock right before it's stored/written. name defines the type of filter to use, expr is the expression to evaluate. You can use the option several times, and each use appends more expression to the same name. ๐ŸŽ€

So the filter types you can pick from are:

  • keep-uid โ€” keeps a user ID packet and its dependent packets in the keyblock if the expression evaluates to true.
  • drop-subkey โ€” drops the selected subkeys. Currently only implemented for --export-filter.
  • drop-sig โ€” drops the selected key signatures on user IDs. Self-signatures are not considered. Currently only implemented for --import-filter.
  • select โ€” only implemented by --list-filter. All property names may be used.

For the syntax of the expression, see the chapter "FILTER EXPRESSIONS". The property names for the expressions depend on the actual filter type and are indicated in the list below โ€” and note that all property names may also be used by --list-filter. ๐Ÿ’–

Property names may be prefixed with a scope delimited by a slash. Valid scopes are "pub" for public and secret primary keys, "sub" for public and secret subkeys, "uid" for user-ID packets, and "sig" for signature packets. Invalid scopes are currently ignored.

The available properties are:

  • uid โ€” a string with the user id. (keep-uid)
  • mbox โ€” the addr-spec part of a user id with mailbox, or the empty string. (keep-uid)
  • algostr โ€” a string with the key algorithm description. For example "rsa3072" or "ed25519".
  • key_algo โ€” a number with the public key algorithm of a key or subkey packet. (drop-subkey)
  • key_size โ€” a number with the effective key size of a key or subkey packet. (drop-subkey)
  • key_created, key_created_d โ€” the first is the timestamp a public key or subkey packet was created. The second is the same but given as an ISO string, e.g. "2016-08-17". (drop-subkey)
  • key_expires, key_expires_d โ€” the expiration time of a public key or subkey, or 0 if it does not expire. The second is the same but given as an ISO date string or an empty string, e.g. "2038-01-19".
  • fpr โ€” the hexified fingerprint of the current subkey or primary key. (drop-subkey)
  • primary โ€” boolean indicating whether the user id is the primary one. (keep-uid)
  • expired โ€” boolean indicating whether a user id (keep-uid), a key (drop-subkey), or a signature (drop-sig) expired.
  • revoked โ€” boolean indicating whether a user id (keep-uid) or a key (drop-subkey) has been revoked.
  • disabled โ€” boolean indicating whether a primary key is disabled.
  • secret โ€” boolean indicating whether a key or subkey is a secret one. (drop-subkey)
  • usage โ€” a string indicating the usage flags for the subkey, from the sequence ecsa?. For example, a subkey capable of just signing and authentication would be an exact match for sa. (drop-subkey)
  • sig_created, sig_created_d โ€” the first is the timestamp a signature packet was created. The second is the same but given as an ISO date string, e.g. "2016-08-17". (drop-sig)
  • sig_expires, sig_expires_d โ€” the expiration time of a signature packet, or 0 if it does not expire. The second is the same but given as an ISO date string or an empty string, e.g. "2038-01-19".
  • sig_algo โ€” a number with the public key algorithm of a signature packet. (drop-sig)
  • sig_digest_algo โ€” a number with the digest algorithm of a signature packet. (drop-sig)
  • origin โ€” a string with the key origin or a question mark. For example the string wkd is used if a key originated from a Web Key Directory lookup.
  • lastupd โ€” the timestamp the key was last updated from a keyserver or the Web Key Directory.
  • url โ€” a string with the URL associated with the last key lookup. ๐Ÿ”

  • --export-options parameters โ€” a space or comma delimited string that gives options for exporting keys. Options can be prepended with a no- to give the opposite meaning. The options are:
    • export-local-sigs โ€” allow exporting key signatures marked as "local". This is not generally useful unless a shared keyring scheme is being used. Defaults to no.
    • export-attributes โ€” include attribute user IDs (photo IDs) while exporting. Not including attribute user IDs is useful for exporting keys that are going to be used by an OpenPGP program that doesn't accept attribute user IDs. Defaults to yes.
    • export-sensitive-revkeys โ€” include designated revoker information that was marked as "sensitive". Defaults to no.
    • backup, export-backup โ€” export for use as a backup. The exported data includes all data which is needed to restore the key or keys later with GnuPG. The format is basically the OpenPGP format but enhanced with GnuPG specific data. All other contradicting options are overridden. ๐ŸŒธ
  • export-clean โ€” bestie, this one compacts the user IDs on the key you're exporting, meaning it yeets all the signatures off any user ID that isn't usable ๐Ÿ’…. Also: it won't export any signatures that aren't usable either, and that includes sigs issued by keys that aren't even on your keyring. It's literally the same as running the --edit-key command "clean" before export โ€” except your local copy of the key stays untouched ๐Ÿซถ. Defaults to no.
  • export-minimal โ€” exports the smallest possible key ๐Ÿ”ฅ. It strips every signature except the most recent self-signature on each user ID. Same vibe as running the --edit-key command "minimize" before export, except again, your local copy is not modified. Defaults to no.
  • export-revocs โ€” exports only the standalone revocation certificates of the key. It does not export revocations of 3rd party certificate revocations, okurrr ๐Ÿ’€.
  • export-dane โ€” instead of dumping the key material, it outputs OpenPGP DANE records that are suitable to drop into DNS zone files ๐ŸŒ. An ORIGIN line gets printed before each record so you can divert the records to the corresponding zone file. Very demure, very DNS.
  • mode1003 โ€” turns on the use of a shiny new secret key export format โœจ. This format avoids the re-encryption that the current OpenPGP format requires, and it also improves the security of the secret key if it's been protected with a passphrase. But โ€” and this is the important part โ€” an unprotected key is exported as-is and is therefore not secure ๐Ÿ˜ญ. The general rule about conveying secret keys in an OpenPGP encrypted file still applies with this mode. Also: versions of GnuPG before 2.4.0 are not able to import such a secret file, so likeโ€ฆ be careful who you send it to ๐Ÿ™ˆ.

  • --with-colons โ€” prints key listings delimited by colons ๐Ÿ’…. Heads up: the output will be encoded in UTF-8 regardless of any --display-charset setting. This format is the moment for scripts and other programs calling GnuPG, because it's easily machine parsed ๐ŸŽ€. The details of this format are documented in the file doc/DETAILS, which is included in the GnuPG source distribution.
  • --fixed-list-mode โ€” stop merging the primary user ID and the primary key in --with-colon listing mode, and print all timestamps as seconds since 1970-01-01. Since GnuPG 2.0.10 this mode is always used, so this option is obsolete ๐Ÿฆ‹. It does not harm to use it though, so no stress.
  • --legacy-list-mode โ€” reverts to the pre-2.1 public key list mode. This only affects the human readable output, not the machine interface (i.e. --with-colons) ๐Ÿงš. Note that the legacy format does not convey suitable information for elliptic curves โ€” so like, keep that in mind ๐Ÿ’€.
  • --with-fingerprint โ€” same as the command --fingerprint, but it changes only the format of the output, and it may be used together with another command ๐Ÿ‘‘.
  • --with-subkey-fingerprint โ€” if a fingerprint is printed for the primary key, this forces printing of the fingerprint for all subkeys ๐Ÿ”ฅ. You could also achieve this by using --with-fingerprint twice, but if you use this option along with keyid-format "none", a compact fingerprint is printed. Slay.
  • --with-v5-fingerprint โ€” in a colon mode listing, emits "fp2" lines for version 4 OpenPGP keys that have a v5 style fingerprint of the key ๐ŸŒธ.
  • --with-icao-spelling โ€” prints the ICAO spelling of the fingerprint in addition to the hex digits โœˆ๏ธ. Cute for reading out loud.
  • --with-keygrip โ€” includes the keygrip in the key listings ๐Ÿ’œ. In --with-colons mode this is implicitly enabled for secret keys.
  • --with-key-origin โ€” includes the locally held information about the origin and last update of a key in a key listing ๐Ÿฆ‹. In --with-colons mode this is always printed. This data is currently experimental and shall not be considered part of the stable API โ€” so don't go building your whole personality on it, ngl.
  • --with-wkd-hash โ€” prints a Web Key Directory identifier along with each user ID in key listings ๐ŸŽ€. This is an experimental feature and the semantics may change.
  • --with-secret โ€” includes info about the presence of a secret key in public key listings done with --with-colons ๐Ÿ™ˆ.

โœจ OpenPGP protocol specific options โœจ

  • --force-ocb, --force-aead โ€” forces the use of AEAD encryption over MDC encryption ๐Ÿ”ฅ. AEAD is literally the modern, faster way to do authenticated encryption compared to the old MDC method. --force-aead is an alias and it's deprecated, so likeโ€ฆ use the other one bestie. See also option --chunk-size.
  • --force-mdc, --disable-mdc โ€” these options are obsolete and have no effect since GnuPG 2.2.8 ๐Ÿ’€. The MDC is always used unless the keys indicate that an AEAD algorithm can be used, in which case AEAD is used. But note: if the creation of a legacy non-MDC message is exceptionally required, the option --rfc2440 allows for this. Exceptionally, okay? ๐Ÿ˜ญ
  • --disable-signer-uid โ€” by default, the user ID of the signing key is embedded in the data signature. As of now this is only done if the signing key has been specified with local-user using a mail address, or with sender ๐ŸŒธ. This information can be helpful for the verifier to locate the key; see option --auto-key-retrieve.
  • --include-key-block, --no-include-key-block โ€” used to embed the actual signing key into a data signature ๐Ÿซถ. The embedded key is stripped down to a single user id and includes only the signing subkey used to create the signature, as well as valid encryption subkeys. All other info is removed from the key to keep it โ€” and therefore the signature โ€” small. This option is the OpenPGP counterpart to the gpgsm option --include-certs, and it allows the recipient of a signed message to reply encrypted to the sender without using any online directories to look up the key ๐Ÿ‘‘. The default is --no-include-key-block. See also the option --auto-key-import.
  • --personal-cipher-preferences string โ€” sets the list of personal cipher preferences to string. Use gpg --version to get a list of available algorithms, and use none to set no preference at all ๐Ÿ’…. This lets the user safely override the algorithm chosen by the recipient key preferences, since GPG will only select an algorithm that is usable by all recipients. The most highly ranked cipher in this list is also used for the --symmetric encryption command.
  • --personal-digest-preferences string โ€” sets the list of personal digest preferences to string. Use gpg --version to get a list of available algorithms, and use none to set no preference at all โœจ. This lets the user safely override the algorithm chosen by recipient key preferences, since GPG only selects an algorithm usable by all recipients. The most highly ranked digest algorithm in this list is also used when signing without encryption (e.g. --clear-sign or --sign).
  • --personal-compress-preferences string โ€” sets the list of personal compression preferences to string. Use gpg --version to get a list of available algorithms, and use none to set no preference at all ๐ŸŽ€. Same deal: it safely overrides the algorithm chosen by recipient key preferences, because GPG only selects an algorithm usable by all recipients. The most highly ranked compression algorithm in this list is also used when there are no recipient keys to consider (e.g. --symmetric).
  • --s2k-cipher-algo name โ€” uses name as the cipher algorithm for symmetric encryption with a passphrase, if --personal-cipher-preferences and --cipher-algo are not given ๐Ÿ’œ. The default is AES-128.
  • --s2k-digest-algo name โ€” uses name as the digest algorithm used to mangle the passphrases for symmetric encryption ๐ŸŒ€. The default is SHA-1.
  • --s2k-mode n โ€” selects how passphrases for symmetric encryption are mangled. If n is 0, a plain passphrase will be used (which is in general not recommended ๐Ÿ˜ญ). A 1 adds a salt to the passphrase (which should not be used). And a 3 โ€” the default โ€” iterates the whole process a number of times (see --s2k-count) ๐ŸŒˆ.
  • --s2k-count n โ€” specifies how many times the passphrase mangling for symmetric encryption is repeated. This value may range between 1024 and 65011712 inclusive ๐Ÿ”ข. The default is inquired from gpg-agent. Note that not all values in the 1024-65011712 range are legal, and if an illegal value is selected, GnuPG will round up to the nearest legal value ๐Ÿ™ˆ. This option is only meaningful if --s2k-mode is set to the default of 3.

โœจ Compliance options โœจ

These options control what GnuPG is compliant to ๐Ÿ’…. Only one of these options may be active at a time. Note that the default setting of this is nearly always the correct one ๐Ÿ‘‘. See the INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS section below before using one of these options โ€” like, fr fr, read that first.

  • --gnupg โ€” use standard GnuPG behavior. This is essentially OpenPGP behavior (see --openpgp), but with extensions from the proposed update to OpenPGP and with some additional workarounds for common compatibility problems in different versions of PGP ๐Ÿฆ‹. This is the default option, so it's not generally needed, but it may be useful to override a different compliance option in the gpg.conf file.
  • --openpgp โ€” resets all packet, cipher and digest options to strict OpenPGP behavior โœจ. This option implies --allow-old-cipher-algos. Use this option to reset all previous options like --s2k-*, --cipher-algo, --digest-algo and --compress-algo to OpenPGP compliant values. All PGP workarounds are disabled ๐Ÿ’€.
  • --rfc4880 โ€” resets all packet, cipher and digest options to strict RFC-4880 behavior ๐ŸŽ€. This option implies --allow-old-cipher-algos. Note that this is currently the same thing as --openpgp.
  • --rfc4880bis โ€” resets all packet, cipher and digest options to strict behavior according to the proposed updates of RFC-4880 ๐ŸŒธ.
  • --rfc2440 โ€” resets, like, every packet, cipher and digest option back to strict RFC-2440 behavior. heads up bestie: using this creates encryption packets in a legacy mode with no MDC protection, which is dangerous and should only ever be used for experiments. ๐Ÿซถ This option implies --allow-old-cipher-algos. See also --ignore-mdc-error.
  • --pgp6 โ€” this option is obsolete; it gets handled as an alias for --pgp7. it's giving "I'm here but I do nothing" ๐Ÿ’€
  • --pgp7 โ€” sets up all the options to be as PGP 7 compliant as possible. That means the ciphers IDEA, 3DES, CAST5,AES128, AES192, AES256, and TWOFISH. โ€” yes the manpage really wrote it like that, don't come for me ๐ŸŽ€ โ€” plus the hashes MD5, SHA1 and RIPEMD160, and the compression algorithms none and ZIP. This option implies --escape-from-lines and disables --throw-keyids.
  • --pgp8 โ€” sets up all options to be as PGP 8 compliant as possible. PGP 8 is so much closer to the OpenPGP standard than earlier PGP versions, so honestly all this does is disable --throw-keyids and set --escape-from-lines. All algorithms are allowed except for the SHA224, SHA384, and SHA512 digests. simple, clean, iconic โœจ
  • --compliance string โ€” you can use this instead of any one of the options above. Valid values for string are the above option names (without the double dash) and possibly others, as shown when you use "help" for string. iykyk
  • --min-rsa-length n โ€” tweaks the compliance mode "de-vs" for stricter key size requirements. For example, a value of 3000 turns rsa2048 and dsa2048 keys into non-VS-NfD compliant keys. ๐Ÿ”ฅ
  • --require-compliance โ€” normally, to check that data has been encrypted according to the rules of the current compliance mode, a gpg user has to evaluate the status lines. This lets frontends handle the compliance check in a more flexible way. But for scripted use, evaluating those status lines is a whole lot of effort, so this option exists instead: it makes sure the gpg process exits with a failure if the compliance rules are not fulfilled. note that this option currently only has an effect in "de-vs" mode.

๐Ÿ™ˆ Doing things one usually doesn't want to do ๐Ÿ™ˆ

the "don't touch that" shelf, basically ๐Ÿ“

  • -n, --dry-run โ€” don't make any changes. (this is not completely implemented, so likeโ€ฆ mostly.) ๐Ÿ˜ญ
  • --list-only โ€” changes the behaviour of some commands. It's like --dry-run but different in some cases. The semantics of this option may be extended in the future. Currently it only skips the actual decryption pass, which enables a fast listing of the encryption keys. speedrun strats โšก
  • -i, --interactive โ€” prompts before overwriting any files. polite queen behavior ๐Ÿ‘‘
  • --compatibility-flags flags โ€” sets compatibility flags to work around problems caused by non-compliant keys or data. The flags are given as a comma separated list of flag names and are OR-ed together. The special flag "none" clears the list so you can start over with an empty one. To get a list of available flags, use the sole word "help". ๐Ÿฆ‹
  • --debug-level level โ€” picks the debug level for investigating problems. level may be a numeric value or one of these keywords:
    • none โ€” no debugging at all. A value of less than 1 may be used instead of the keyword.
    • basic โ€” some basic debug messages. A value between 1 and 2 may be used instead of the keyword.
    • advanced โ€” more verbose debug messages. A value between 3 and 5 may be used instead of the keyword.
    • expert โ€” even more detailed messages. A value between 6 and 8 may be used instead of the keyword.
    • guru โ€” all of the debug messages you can get. A value greater than 8 may be used instead of the keyword. The creation of hash tracing files is only enabled if the keyword is used. guru mode, main character energy ๐Ÿงš

How these messages are mapped to the actual debugging flags is not specified and may change with newer releases of this program. They are, however, carefully selected to best aid in debugging. ๐Ÿ’œ

  • --debug flags โ€” sets debug flags. All flags are OR-ed and flags may be given in C syntax (e.g. 0x0042) or as a comma separated list of flag names. To get a list of all supported flags, the single word "help" can be used. This option is only useful for debugging and the behavior may change at any time without notice. ๐Ÿ’€
  • --debug-all โ€” sets all useful debugging flags. all of them. every last one. ๐Ÿ”ฅ
  • --debug-iolbf โ€” sets stdout into line buffered mode. This option is only honored when given on the command line.
  • --debug-set-iobuf-size n โ€” changes the buffer size of the IOBUFs to n kilobyte. Using 0 prints the current size. Note well: this is a maintainer only option and may thus be changed or removed at any time without notice. ๐Ÿซถ
  • --debug-allow-large-chunks โ€” to facilitate software tests and experiments, this option lets you specify a limit of up to 4 EiB (--chunk-size 62). four. exabytes. bestie. ๐Ÿ˜ญ
  • --debug-ignore-expiration โ€” this option tries to override certain key expiration dates. It's only useful for certain regression tests.
  • --faked-system-time epoch โ€” only useful for testing; it sets the system time back or forth to epoch, which is the number of seconds elapsed since the year 1970. Alternatively, epoch may be given as a full ISO time string (e.g. "20070924T154812").

If you suffix epoch with an exclamation mark (!), the system time will appear to be frozen at the specified time. time travel slay ๐Ÿฆ‹

  • --full-timestrings โ€” changes the format of printed creation and expiration times from just the date to the date and time. This is in general not useful, and the same information is anyway available in --with-colons mode. These longer strings are also not well aligned with other printed data. aesthetic downgrade ngl ๐Ÿ™ˆ
  • --enable-progress-filter โ€” enables certain PROGRESS status outputs. This option lets frontends display a progress indicator while gpg is processing larger files. There is a slight performance overhead using it. โญ
  • --status-fd n โ€” writes special status strings to the file descriptor n. See the file DETAILS in the documentation for a listing of them.
  • --status-file file โ€” same as --status-fd, except the status data is written to file.
  • --logger-fd n โ€” writes log output to file descriptor n and not to STDERR.
  • --log-file file, --logger-file file โ€” same as --logger-fd, except the logger data is written to file. Use โ€˜socket://โ€™ to log to a socket. ๐Ÿ”Œ
  • --log-time โ€” prefixes all log output with a timestamp even if no log file is used. timestamps are self care ๐ŸŽ€
  • --attribute-fd n โ€” writes attribute subpackets to the file descriptor n. This is most useful with --status-fd, since the status messages are needed to separate out the various subpackets from the stream delivered to the file descriptor. ๐Ÿ’…
  • --attribute-file file โ€” same as --attribute-fd, except the attribute data is written to file.
  • --comment string, --no-comments โ€” uses string as a comment string in cleartext signatures and ASCII armored messages or keys (see --armor). The default behavior is to not use a comment string. --comment may be repeated multiple times to get multiple comment strings. --no-comments removes all comments. It's a good idea to keep the length of a single comment below 60 characters to avoid problems with mail programs wrapping such lines. Note that comment lines, like all other header lines, are not protected by the signature. ๐Ÿซถ
  • --emit-version, --no-emit-version โ€” forces inclusion of the version string in ASCII armored output. If given once, only the name of the program and the major number is emitted; given twice, the minor is also emitted; given thrice, the micro is added; and given four times, an operating system identification is also emitted. --no-emit-version (the default) disables the version line. count them. I dare you. ๐Ÿ˜ญ
  • --sig-notation {name=value}, --cert-notation {name=value}, -N, --set-notation {name=value} โ€” puts the name value pair into the signature as notation data. name must consist only of printable characters or spaces, and must contain a '@' character in the form keyname@domain.example.com (substituting the appropriate keyname and domain name, of course). This is to help prevent pollution of the IETF reserved notation namespace. The --expert flag overrides the '@' check. value may be any printable string; it will be encoded in UTF-8, so you should check that your --display-charset is set correctly. If you prefix name with an exclamation mark (!), the notation data will be flagged as critical (rfc4880:5.2.3.16). --sig-notation sets a notation for data signatures. --cert-notation sets a notation for key signatures (certifications). --set-notation sets both. โœจ

There are special codes that may be used in notation names. "%k" will be expanded into the key ID of the key being signed, "%K" into the long key ID of the key being signed, "%f" into the fingerprint of the key being signed, "%s" into the key ID of the key making the signature, "%S" into the long key ID of the key making the signature, "%g" into the fingerprint of the key making the signature (which might be a subkey), "%p" into the fingerprint of the primary key of the key making the signature, "%c" into the signature count from the OpenPGP smartcard, and "%%" results in a single "%". %k, %K, and %f are only meaningful when making a key signature (certification), and %c is only meaningful when using the OpenPGP smartcard. ๐ŸŽ€

  • --known-notation name โ€” adds name to a list of known critical signature notations. The effect of this is that gpg will not mark a signature with a critical signature notation of that name as bad. Note that gpg already knows by default about a few critical signature notation names. it already knows. it's been around. ๐Ÿ‘‘
  • --sig-policy-url string, --cert-policy-url string, --set-policy-url string โ€” okay so this sets a Policy URL for signatures, and the spec ref is rfc4880:5.2.3.20 if you wanna look it up ๐Ÿ’–. Slap an exclamation mark (!) at the front of string and the policy URL packet gets flagged as critical โ€” like, "babe this is not optional" energy. --sig-policy-url sets a policy url for data signatures, --cert-policy-url sets one for key signatures (certifications), and --set-policy-url is the overachiever that does both. And the same %-expandos used for notation data work here too โœจ.
  • --sig-keyserver-url string โ€” uses string as a preferred keyserver URL for data signatures ๐Ÿฆ‹. Prefix it with ! and the keyserver URL packet gets flagged as critical, same deal as above. The same %-expandos used for notation data are available here as well, no cap.
  • --set-filename string โ€” uses string as the filename that gets stored inside messages ๐ŸŽ€. This overrides the default, which is just... the actual filename of the file you're encrypting. Use the empty string for string and it effectively removes the filename from the output entirely (poof, gone, iconic).
  • --for-your-eyes-only, --no-for-your-eyes-only โ€” sets the for your eyes only flag in the message ๐Ÿ™ˆ. This makes GnuPG refuse to save the file unless you also gave --output, and makes PGP use a "secure viewer" with a claimed Tempest-resistant font to display the message (yes that's really the description, don't @ me). This option overrides --set-filename. --no-for-your-eyes-only disables it, bestie.
  • --use-embedded-filename, --no-use-embedded-filename โ€” tries to create a file with the name embedded in the data. โš ๏ธ Heads up: this can be a dangerous option because it enables overwriting files by giving the sender control over how files get stored. Defaults to no. Also note that --output overrides this option.

A better approach than using this option is to decrypt to a temporary filename and then rename that file to the embedded filename after checking that the embedded filename is harmless ๐Ÿ’…. When you use --status-fd, gpg tells you the filename as part of the PLAINTEXT status message. If the filename matters to you, gpgtar is another option โ€” because gpgtar will never overwrite a file, it just decrypts the files into a new directory. Also note: unless a modern version 5 signature is used, the embedded filename is not part of the signed data (lowkey terrifying, stay safe out there).

  • --cipher-algo name โ€” uses name as the cipher algorithm ๐Ÿ”ฅ. Run the program with --version and it'll hand you a list of supported algorithms. If you don't set this, the cipher algorithm gets picked from the preferences stored with the key. In general, you do not want to use this option, because it lets you violate the OpenPGP standard ๐Ÿ˜ญ. --personal-cipher-preferences is the safe way to accomplish the same thing.
  • --digest-algo name โ€” uses name as the message digest algorithm ๐ŸŒธ. --version gives you the list of supported algorithms. In general, you do not want to use this option as it allows you to violate the OpenPGP standard. --personal-digest-preferences is the safe way to accomplish the same thing.
  • --compress-algo name โ€” uses compression algorithm name โœจ. Let's break it down:
    • "zlib" is RFC-1950 ZLIB compression.
    • "zip" is RFC-1951 ZIP compression, which is what PGP uses.
    • "bzip2" is a more modern compression scheme that can compress some things better than zip or zlib, but at the cost of more memory used during compression and decompression.
    • "uncompressed" or "none" disables compression.

If this option isn't used, the default behavior is to examine the recipient key preferences to see which algorithms the recipient supports. If all else fails, ZIP is used for maximum compatibility.

ZLIB may give better compression results than ZIP, since the compression window size isn't limited to 8k. BZIP2 may give even better compression results than that, but it'll use a significantly larger amount of memory while compressing and decompressing โ€” which may be significant in low memory situations. Note, however, that PGP (all versions) only supports ZIP compression, so using any algorithm other than ZIP or "none" will make the message unreadable with PGP ๐Ÿ’€. In general, you do not want to use this option as it allows you to violate the OpenPGP standard. --personal-compress-preferences is the safe way to accomplish the same thing.

  • --cert-digest-algo name โ€” uses name as the message digest algorithm used when signing a key ๐Ÿ‘‘. --version gives you the list of supported algorithms. Be aware that if you choose an algorithm that GnuPG supports but other OpenPGP implementations don't, then some users will not be able to use the key signatures you make โ€” or quite possibly your entire key ๐Ÿ˜ฌ. Also note that a public key algorithm must be compatible with the specified digest algorithm, so selecting an arbitrary digest algorithm may result in error messages from lower crypto layers or lead to security flaws. Not it.
  • --disable-cipher-algo name โ€” never allows the use of name as cipher algorithm ๐Ÿšซ. The given name will not be checked, so that a later loaded algorithm will still get disabled.
  • --disable-pubkey-algo name โ€” never allows the use of name as public key algorithm ๐Ÿšซ. The given name will not be checked, so that a later loaded algorithm will still get disabled.
  • --throw-keyids, --no-throw-keyids โ€” do not put the recipient key IDs into encrypted messages ๐Ÿ•ต๏ธ. This helps hide the receivers of the message and is a limited countermeasure against traffic analysis (as in โ€” using a little social engineering, anyone who is able to decrypt the message can check whether one of the other recipients is the one he suspects). On the receiving side, it may slow down the decryption process because all available secret keys must be tried ๐Ÿ˜ญ. --no-throw-keyids disables this option. This option is essentially the same as using --hidden-recipient for all recipients.
  • --not-dash-escaped โ€” this option changes the behavior of cleartext signatures so they can be used for patch files ๐Ÿฉน. You should not send such an armored file via email because all spaces and line endings are hashed too. You can not use this option for data which has 5 dashes at the beginning of a line โ€” patch files don't have this, so we're chillin'. A special armor header line tells GnuPG about this cleartext signature option.
  • --escape-from-lines, --no-escape-from-lines โ€” because some mailers change lines starting with "From " to ">From ", it's good to handle such lines in a special way when creating cleartext signatures, so the mail system doesn't break the signature ๐Ÿ“ง. Note that all other PGP versions do it this way too. Enabled by default. --no-escape-from-lines disables this option.
  • --passphrase-repeat n โ€” specifies how many times gpg will request a new passphrase be repeated ๐Ÿ”. This is useful for helping memorize a passphrase (very "write it on a sticky note but don't" of you). Defaults to 1 repetition; can be set to 0 to disable any passphrase repetition. Note that an n greater than 1 will pop up the pinentry window n+1 times even if a modern pinentry with two entry fields is used.
  • --passphrase-fd n โ€” reads the passphrase from file descriptor n ๐Ÿ’œ. Only the first line will be read from file descriptor n. If you use 0 for n, the passphrase will be read from STDIN. This can only be used if only one passphrase is supplied.

Note that since Version 2.0 this passphrase is only used if the option --batch has also been given. Since Version 2.1 the --pinentry-mode also needs to be set to loopback.

  • --passphrase-file file โ€” reads the passphrase from file file ๐Ÿ“. Only the first line will be read from file file. This can only be used if only one passphrase is supplied. Obviously, a passphrase stored in a file is of questionable security if other users can read this file โ€” don't use this option if you can avoid it, fr fr.

Note that since Version 2.0 this passphrase is only used if the option --batch has also been given. Since Version 2.1 the --pinentry-mode also needs to be set to loopback.

  • --passphrase string โ€” uses string as the passphrase ๐Ÿงš. This can only be used if only one passphrase is supplied. Obviously, this is of very questionable security on a multi-user system โ€” don't use this option if you can avoid it.

Note that since Version 2.0 this passphrase is only used if the option --batch has also been given. Since Version 2.1 the --pinentry-mode also needs to be set to loopback.

  • --pinentry-mode mode โ€” sets the pinentry mode to mode ๐Ÿ”. Allowed values for mode are:
    • default โ€” use the default of the agent, which is ask.
    • ask โ€” force the use of the Pinentry.
    • cancel โ€” emulate use of Pinentry's cancel button.
    • error โ€” return a Pinentry error ("No Pinentry").
    • loopback โ€” redirect Pinentry queries to the caller. Note that in contrast to Pinentry the user is not prompted again if he enters a bad password.
  • --no-symkey-cache โ€” disables the passphrase cache used for symmetrical en- and decryption ๐Ÿ™…. This cache is based on the message specific salt value (cf. --s2k-mode).
  • --request-origin origin โ€” tells gpg to assume that the operation ultimately originated at origin ๐ŸŒ. Depending on the origin certain restrictions are applied, and the Pinentry may include an extra note on the origin. Supported values for origin are: local which is the default, remote to indicate a remote origin, or browser for an operation requested by a web browser.
  • --command-fd n โ€” this is a replacement for the deprecated shared-memory IPC mode ๐Ÿ“ผ. If this option is enabled, user input on questions isn't expected from the TTY but from the given file descriptor. It should be used together with --status-fd. See the file doc/DETAILS in the source distribution for details on how to use it.
  • --command-file file โ€” same as --command-fd, except the commands are read out of file file ๐Ÿ“„.
  • --allow-non-selfsigned-uid, --no-allow-non-selfsigned-uid โ€” bestie, this lets you import and use keys whose user IDs are not self-signed. And likeโ€ฆ don't? ๐Ÿšฉ A non self-signed user ID is literally trivial to forge, so this is not recommended at all. --no-allow-non-selfsigned-uid turns it back off.
  • --allow-freeform-uid โ€” turns off all the checks on the form of the user ID while you're generating a new one. Only use this in very special environments, okay? Because it does not ensure the de-facto standard format of user IDs. It's giving "chaos by choice" ๐Ÿ’€
  • --ignore-time-conflict โ€” normally GnuPG checks that the timestamps on keys and signatures have plausible values. But sometimes, because of clock problems, a signature seems older than the key it's on ๐Ÿ˜ญ This option downgrades those checks to just a warning. Also peep --ignore-valid-from for timestamp drama on subkeys.
  • --ignore-valid-from โ€” GnuPG normally does not select and use subkeys created in the future (yes, future, iconic โœจ). This option lets you use those keys anyway and therefore exhibits the pre-1.0.7 behaviour. Don't use it unless you've got some clock problem, fr. See also --ignore-time-conflict for timestamp issues with signatures.
  • --ignore-crc-error โ€” the ASCII armor OpenPGP uses is protected by a CRC checksum against transmission errors. Occasionally the CRC gets mangled somewhere on the transmission channel, but the actual content (which the OpenPGP protocol protects anyway, slay) is still fine. This option lets GnuPG ignore those CRC errors ๐Ÿซถ
  • --ignore-mdc-error โ€” this one turns an MDC integrity protection failure into a warning. You need it to decrypt old messages that didn't use an MDC. It can also be useful when a message is partially garbled and you need to get as much data as possible out of that garbled message. But โ€” and this is the important part โ€” a missing or failed MDC can be an indication of an attack โš ๏ธ Use with great caution; see also option --rfc2440.
  • --allow-old-cipher-algos โ€” old cipher algorithms like 3DES, IDEA, or CAST5 encrypt data using blocks of 64 bits; modern algorithms use blocks of 128 bit instead. To avoid certain attacks on these old algorithms it's suggested not to encrypt more than 150 MiByte using the same key. For this reason gpg does not allow the use of 64 bit block size algorithms for encryption unless you specify this option ๐Ÿ‘‘
  • --allow-weak-digest-algos โ€” signatures made with known-weak digest algorithms are normally rejected with an invalid digest algorithm message. This option allows verification of signatures made with those weak algorithms. MD5 is the only digest algorithm considered weak by default. See also --weak-digest to reject other digest algorithms.
  • *--weak-digest name* โ€” treat the specified digest algorithm as weak. Signatures made over weak digest algorithms are normally rejected. You can supply this option multiple times if multiple algorithms should be considered weak ๐Ÿ’… See also --allow-weak-digest-algos to disable rejection of weak digests. MD5 is always considered weak, and doesn't need to be listed explicitly.
  • --allow-weak-key-signatures โ€” to avoid a minor risk of collision attacks on third-party key signatures made using SHA-1, those key signatures are considered invalid. This option lets you override that restriction.
  • --override-compliance-check โ€” this was a temporary introduced option and has no more effect. Flop era, honestly ๐Ÿ’€
  • --no-default-keyring โ€” do not add the default keyring to the list of keyrings. But heads up: GnuPG needs a keyring for almost all operations, so if you use this option and don't provide alternate keyrings via --keyring, then GnuPG will still use the default keyring ๐Ÿ˜ญ

Also note: if the option use-keyboxd is enabled in common.conf, no keyrings are used at all and keys are all maintained by the keyboxd process in its own database.

  • --no-keyring โ€” do not use any keyring at all. This overrides the default and all options which specify keyrings. Total main character energy, zero keyrings ๐Ÿ”ฅ
  • --skip-verify โ€” skip the signature verification step. Can be used to make the decryption faster if the signature verification isn't needed. Speedy little shortcut โšก
  • --with-key-data โ€” print key listings delimited by colons (like --with-colons) and print the public key data.
  • --list-signatures, --list-sigs โ€” same as --list-keys, but the signatures are listed too. This command has the same effect as using --list-keys with --with-sig-list. Note that in contrast to --check-signatures the key signatures are not verified. This command can be used to create a list of signing keys missing in the local keyring; for example:
 gpg --list-sigs --with-colons USERID | \
   awk -F: '$1=="sig" && $2=="?" {if($13){print $13}else{print $5}}'
  • --fast-list-mode โ€” changes the output of the list commands to work faster; this is achieved by leaving some parts empty. Some applications don't need the user ID and the trust information given in the listings, and by using this option they can get a faster listing. The exact behaviour of this option may change in future versions ๐Ÿ‘€ If you're missing some information, don't use this option.
  • --no-literal โ€” this is not for normal use. Use the source to see for what it might be useful. Mysterious much? ๐Ÿ™ˆ
  • --set-filesize โ€” this is not for normal use either. Use the source to see for what it might be useful.
  • --show-session-key โ€” display the session key used for one message. See --override-session-key for the counterpart of this option.

We think that Key Escrow is a Bad Thing; however the user should have the freedom to decide whether to go to prison or to reveal the content of one specific message without compromising all messages ever encrypted for one secret key ๐Ÿ˜ญ๐Ÿซถ

You can also use this option if you receive an encrypted message which is abusive or offensive, to prove to the administrators of the messaging system that the ciphertext transmitted corresponds to an inappropriate plaintext, so they can take action against the offending user. Genuinely iconic use case, ngl ๐Ÿ‘‘

  • *--override-session-key string, --override-session-key-fd fd* โ€” don't use the public key but the session key string respective the session key taken from the first line read from file descriptor fd. The format of this string is the same as the one printed by --show-session-key. This option is normally not used but comes handy in case someone forces you to reveal the content of an encrypted message; using this option you can do this without handing out the secret key ๐Ÿซถ Note that using --override-session-key may reveal the session key to all local users via the global process table. Often it's useful to combine this option with --no-keyring.
  • --ask-sig-expire, --no-ask-sig-expire โ€” when making a data signature, prompt for an expiration time. If this option isn't specified, the expiration time set via --default-sig-expire is used. --no-ask-sig-expire disables this option.
  • --default-sig-expire โ€” the default expiration time to use for signature expiration โœจ Valid values are "0" for no expiration, a number followed by the letter d (for days), w (for weeks), m (for months), or y (for years) (for example "2m" for two months, or "5y" for five years), or an absolute date in the form YYYY-MM-DD. Defaults to "0".
  • --ask-cert-expire, --no-ask-cert-expire โ€” when making a key signature, prompt for an expiration time. If this option isn't specified, the expiration time set via --default-cert-expire is used. --no-ask-cert-expire disables this option.
  • --default-cert-expire โ€” the default expiration time to use for key signature expiration ๐Ÿ’– Valid values are "0" for no expiration, a number followed by the letter d (for days), w (for weeks), m (for months), or y (for years) (for example "2m" for two months, or "5y" for five years), or an absolute date in the form YYYY-MM-DD. Defaults to "0".
  • *--default-new-key-algo string* โ€” this option can be used to change the default algorithms for key generation. The string is similar to the arguments required for the command --quick-add-key but slightly different. For example the current default of "rsa2048/cert,sign+rsa2048/encr" (or "rsa3072") can be changed to the value of what we currently call future default, which is "ed25519/cert,sign+cv25519/encr" ๐Ÿฆ‹ You need to consult the source code to learn the details. Note that the advanced key generation commands can always be used to specify a key algorithm directly.
  • --no-auto-trust-new-key โ€” when creating a new key the ownertrust of the new key is set to ultimate. This option disables that, and the user needs to manually assign an ownertrust value. You're in charge now ๐Ÿ’…
  • --force-sign-key โ€” this option modifies the behaviour of the commands --quick-sign-key, --quick-lsign-key, and the "sign" sub-commands of --edit-key by forcing the creation of a key signature, even if one already exists. Duplicates? We don't care, we're forcing it ๐Ÿ˜ค
  • --forbid-gen-key โ€” this option is intended for use in the global config file to disallow the use of generate key commands. Those commands will then fail with the error code for Not Enabled. No key-gen for you ๐Ÿšซ
  • --allow-secret-key-import โ€” this is an obsolete option and is not used anywhere. She's retired, respectfully ๐Ÿ’€
  • --allow-multiple-messages, --no-allow-multiple-messages โ€” these are obsolete options; they have no more effect since GnuPG 2.2.8.
  • --enable-special-filenames โ€” this option enables a mode in which filenames of the form -&n, where n is a non-negative decimal number, refer to the file descriptor n and not to a file with that name. Little file-descriptor magic trick โœจ
  • --no-expensive-trust-checks โ€” experimental use only. ๐Ÿ”ฌ
  • --preserve-permissions โ€” don't change the permissions of a secret keyring back to user read/write only. Use this option only if you really know what you're doing ๐Ÿ™ˆโš ๏ธ
  • *--default-preference-list string* โ€” set the list of default preferences to string. This preference list is used for new keys and becomes the default for "setpref" in the --edit-key menu. Pre-set your vibes, periodt ๐Ÿ’…
  • --default-keyserver-url name โ€” sets the default keyserver URL to name. This keyserver gets used as the keyserver URL whenever a new self-signature is written on a key, which lowkey includes key generation and changing preferences. ๐Ÿ—๏ธ
  • --list-config โ€” shows you a bunch of GnuPG's internal configuration parameters. Ngl this one is built for external programs that call GnuPG to do tasks, so it's not really for you and me day-to-day. Peep the file doc/DETAILS in the source distribution for the whole rundown of which configuration items can be listed. Word of warning: --list-config is only usable with --with-colons set. ๐Ÿ’…
  • --list-gcrypt-config โ€” displays various internal configuration parameters of Libgcrypt. That's it, that's the whole vibe. โœจ
  • --gpgconf-list โ€” basically --list-config's cousin, but fr only used internally by the gpgconf tool. ๐Ÿซถ
  • --gpgconf-test โ€” more or less a dummy action, bestie. But! It parses the configuration file and returns with failure if the configuration file would prevent gpg from startup โ€” so you can use it to run a syntax check on the config file. Iconic little test. ๐Ÿงช
  • --chuid uid โ€” changes the current user to uid, which can be either a number or a name. This is the one you use from the root account to run gpg for another user. Heads up: if uid isn't the current UID, a standard PATH is set and the envvar GNUPGHOME is unset. To override that last bit you can use the option --homedir. Also this option only has an effect when used on the command line, and currently it has no effect at all on Windows. ๐Ÿ˜ญ

๐Ÿ’€ Deprecated options ๐Ÿ’€

Gather round, these are the retired queens. They still appear in the docs but pls don't build anything new on them. ๐Ÿ™ˆ

  • -t, --textmode / --no-textmode โ€” treats input files as text and stores them in the OpenPGP canonical text form with standard "CRLF" line endings. It also sets the necessary flags to tell the recipient that the encrypted or signed data is text and may need its line endings converted back to whatever the local system uses. Back in the day this was useful when talking between two platforms with different line ending conventions (UNIX-like to Mac, Mac to Windows, etc). --no-textmode disables this option, and it's the default. Note that this is a legacy option which should not anymore be used by any modern software. Periodt. ๐Ÿšซ
  • --force-v3-sigs / --no-force-v3-sigs and --force-v4-certs / --no-force-v4-certs โ€” these options are obsolete and have no effect since GnuPG 2.1. They're literally just vibes at this point. ๐Ÿ’€
  • --show-photos / --no-show-photos โ€” causes --list-keys, --list-signatures, --list-public-keys, --list-secret-keys, and verifying a signature to also display the photo ID attached to the key, if any. See also --photo-viewer. These options are deprecated โ€” use --list-options [no-]show-photos and/or --verify-options [no-]show-photos instead. ๐Ÿ“ธ
  • --show-keyring โ€” displays the keyring name at the head of key listings so you can see which keyring a given key resides on. This option is deprecated: use --list-options [no-]show-keyring instead. ๐Ÿ”‘
  • --show-notation / --no-show-notation โ€” shows signature notations in the --list-signatures or --check-signatures listings, as well as when verifying a signature that has a notation in it. These options are deprecated. Use --list-options [no-]show-notation and/or --verify-options [no-]show-notation instead. ๐Ÿ“
  • --show-policy-url / --no-show-policy-url โ€” shows policy URLs in the --list-signatures or --check-signatures listings, as well as when verifying a signature with a policy URL in it. These options are deprecated. Use --list-options [no-]show-policy-url and/or --verify-options [no-]show-policy-url instead. ๐Ÿ”—
  • --personal-aead-preferences string โ€” this option is deprecated and has no more effect since version 2.3.9. She's retired, respect her legacy. ๐ŸŒธ
  • --aead-algo name โ€” this option is deprecated and has no more effect since version 2.3.9. Same energy. ๐Ÿฆ‹

๐ŸŽ€ EXAMPLES ๐ŸŽ€

Okay bestie, this is the part where it all clicks. Little recipes, go try them (in a safe directory, obviously ๐Ÿ’œ):

gpg -se -r Bob file

sign and encrypt for user Bob ๐Ÿ”ฅ

gpg --clear-sign file

make a cleartext signature โœจ

gpg -sb file

make a detached signature ๐ŸŽ€

gpg -u 0x12345678 -sb file

make a detached signature with the key 0x12345678 ๐Ÿ‘‘

gpg --list-keys user_ID

show keys ๐Ÿ—‚๏ธ

gpg --fingerprint user_ID

show fingerprint ๐Ÿซ†

gpg --verify pgpfile
gpg --verify sigfile [datafile]

Verify the signature of the file but do not output the data unless requested. The second form is the one for detached signatures โ€” sigfile is the detached signature (either ASCII armored or binary) and datafile is the signed data. If datafile isn't given, the name of the file holding the signed data is constructed by cutting off the extension (".asc" or ".sig") of sigfile, or by asking you for the filename like a lost tourist. ๐Ÿงญ If the option --output is also used, the signed data is written to the file specified by that option โ€” use - to write the signed data to stdout. ๐Ÿ’…


๐Ÿ’– HOW TO SPECIFY A USER ID ๐Ÿ’–

So there are actually a lot of different ways to specify a user ID to GnuPG, and it's giving choose-your-own-adventure. Some of them are only valid for gpg, others are only good for gpgsm. Here's the entire list of ways to specify a key โ€” no cap, the whole menu: ๐Ÿ“

๐ŸŒˆ By key Id.

This format is deduced from the length of the string and its content, or the 0x prefix. The key Id of an X.509 certificate is the low 64 bits of its SHA-1 fingerprint. Using key Ids is just a shortcut โ€” for all automated processing, the fingerprint should be used instead. (Yes, this is a read. Use the fingerprint, bestie. ๐Ÿ™)

When using gpg, an exclamation mark (!) may be appended to force using the specified primary or secondary key and not to try and calculate which primary or secondary key to use. Very main character of it.

The last four lines of the example give the key ID in their long form as internally used by the OpenPGP protocol. You can see the long key ID using the option --with-colons. ๐Ÿ‘€

234567C4
0F34E556E
01347A56A
0xAB123456

234AABBCC34567C4
0F323456784E56EAB
01AB3FED1347A5612
0x234AABBCC34567C4

๐Ÿฆ‹ By fingerprint.

This format is deduced from the length of the string and its content, or the 0x prefix. Note that only the 20 byte version fingerprint is available with gpgsm (i.e. the SHA-1 hash of the certificate). ๐Ÿ’…

When using gpg, an exclamation mark (!) may be appended to force using the specified primary or secondary key and not to try and calculate which primary or secondary key to use.

The best way to specify a key Id is by using the fingerprint โ€” this avoids any ambiguities in case that there are duplicated key IDs. It's literally the safe choice. ๐ŸŒŸ

1234343434343434C434343434343434
123434343434343C3434343434343734349A3434
0E12343434343434343434EAB3484343434343434
0xE12343434343434343434EAB3484343434343434

gpgsm also accepts colons between each pair of hexadecimal digits because this is the de-facto standard on how to present X.509 fingerprints. And gpg also allows the use of the space separated SHA-1 fingerprint as printed by the key listing commands. ๐ŸŽ€

๐Ÿงš By exact match on OpenPGP user ID.

This is denoted by a leading equal sign. It does not make sense for X.509 certificates. Ngl it's very specific and very iconic. โœจ

=Heinrich Heine <heinrichh@uni-duesseldorf.de>

๐ŸŒธ By exact match on an email address.

This is indicated by enclosing the email address in the usual way with left and right angles. ๐Ÿซถ

<heinrichh@uni-duesseldorf.de>

๐Ÿ’œ By partial match on an email address.

This is indicated by prefixing the search string with an @. This uses a substring search but considers only the mail address (i.e. inside the angle brackets). Sneaky and efficient. ๐Ÿ‘€

@heinrichh

๐Ÿ”ฅ By exact match on the subject's DN.

This is indicated by a leading slash, directly followed by the RFC-2253 encoded DN of the subject. Note that you can't use the string printed by gpgsm --list-keys because that one has been reordered and modified for better readability; use --with-colons to print the raw (but standard escaped) RFC-2253 string. Don't get caught out by the pretty version, bestie. ๐Ÿ˜ญ

/CN=Heinrich Heine,O=Poets,L=Paris,C=FR

๐Ÿ‘‘ By exact match on the issuer's DN.

This is indicated by a leading hash mark, directly followed by a slash and then directly followed by the RFC-2253 encoded DN of the issuer. This should return the Root cert of the issuer. See note above. ๐ŸŒณ

#/CN=Root Cert,O=Poets,L=Paris,C=FR

โญ By exact match on serial number and issuer's DN.

This is indicated by a hash mark, followed by the hexadecimal representation of the serial number, then followed by a slash and the RFC-2253 encoded DN of the issuer. See note above. ๐Ÿ”ข

#4F03/CN=Root Cert,O=Poets,L=Paris,C=FR

๐ŸŽฏ By keygrip.

This is indicated by an ampersand followed by the 40 hex digits of a keygrip. gpgsm prints the keygrip when using the command --dump-cert. ๐Ÿ’ช

&D75F22C3F86E355877348498CDC92BD21010A480

๐Ÿ“ By substring match.

This is the default mode, but applications may want to explicitly indicate this by putting the asterisk in front. Match is not case sensitive. Chill and forgiving, we love her. ๐Ÿซถ

Heine
*Heine

๐Ÿ’€ . and + prefixes

These prefixes are reserved for looking up mails anchored at the end and for a word search mode. They are not yet implemented and using them is undefined. So likeโ€ฆ don't. ๐Ÿ™ˆ

Please note that we have reused the hash mark identifier which was used in old GnuPG versions to indicate the so called local-id. It is not anymore used and there should be no conflict when used with X.509 stuff.

Using the RFC-2253 format of DNs has the drawback that it is not possible to map them back to the original encoding โ€” however we don't have to do this because our key database stores this encoding as meta data. So it's fine. It's giving "handled." ๐Ÿ’…

FILTER EXPRESSIONS ๐ŸŽ€

okay so the options --import-filter and --export-filter do NOT just take plain words, bestie โ€” they take actual little baby expressions, and the syntax is this (square brackets = optional part, curly braces = repetition, and yes you can put white space between the elements, she's flexible):

           [lc] {[{flag}] PROPNAME op VALUE [lc]}

The name of a property (PROPNAME) may only consist of letters, digits and underscores, no cap. The description for the filter type tells you which properties are actually defined. If you use an undefined property it just evaluates to the empty string, like it's ghosting you softly. And unless otherwise noted, the VALUE must always be given and may not be the empty string. There is no quoting defined for the value, so the value may not contain the strings && or || โ€” those are the logical connection operators, they're booked and busy. The flag -- exists specifically to remove this restriction, iconic of it honestly.

Numerical values are computed as long int; standard C notation applies. lc is the logical connection operator โ€” either && for a conjunction or || for a disjunction. A conjunction is assumed at the begin of an expression. Conjunctions have higher precedence than disjunctions. And heads up ๐Ÿซถ: if VALUE starts with one of the characters used in any op, a space after the op is required. Not optional. Required.

The supported operators (op) are, and I need you to feel these:

  • =~ โ€” substring must match.
  • !~ โ€” substring must not match.
  • = โ€” the full string must match.
  • <> โ€” the full string must not match.
  • == โ€” the numerical value must match.
  • != โ€” the numerical value must not match.
  • <= โ€” the numerical value of the field must be LE than the value.
  • < โ€” the numerical value of the field must be LT than the value.
  • > โ€” the numerical value of the field must be GT than the value.
  • >= โ€” the numerical value of the field must be GE than the value.
  • -le โ€” the string value of the field must be less or equal than the value.
  • -lt โ€” the string value of the field must be less than the value.
  • -gt โ€” the string value of the field must be greater than the value.
  • -ge โ€” the string value of the field must be greater or equal than the value.
  • -n โ€” true if value is not empty (no value allowed).
  • -z โ€” true if value is empty (no value allowed).
  • -t โ€” alias for "PROPNAME != 0" (no value allowed).
  • -f โ€” alias for "PROPNAME == 0" (no value allowed).

Values for flag must be space separated. The supported flags are:

  • -- โ€” VALUE spans to the end of the expression.
  • -c โ€” the string match in this part is done case-sensitive.
  • -t โ€” leading and trailing spaces are not removed from VALUE. The optional single space after op is here required.
๐Ÿ’€ yes there are two -ts in this section, one's an operator and one's a flag, don't come for me, that's just what the page says.

The filter options concatenate several specifications for a filter of the same type. So like, for example, these four options:

                 --import-filter keep-uid="uid =~ Alfa"
                 --import-filter keep-uid="&& uid !~ Test"
                 --import-filter keep-uid="|| uid =~ Alpha"
                 --import-filter keep-uid="uid !~ Test"

which is equivalent to

                 --import-filter \
                  keep-uid="uid =~ Alfa" && uid !~ Test" || uid =~ Alpha" && "uid !~ Test"

imports only the user ids of a key containing the strings "Alfa" or "Alpha" but not the string "test". Slay, that's the whole bit. โœจ


TRUST VALUES ๐Ÿ‘‘

Trust values are used to indicate ownertrust and validity of keys and user IDs. They get displayed as letters or as strings, so here's the whole roster:

  • -, unknown โ€” no ownertrust assigned / not yet calculated.
  • e, expired โ€” trust calculation has failed; probably due to an expired key. ๐Ÿ˜ญ
  • q, undefined, undef โ€” not enough information for calculation.
  • n, never โ€” never trust this key. periodt.
  • m, marginal โ€” marginally trusted.
  • f, full โ€” fully trusted. ๐Ÿ’–
  • u, ultimate โ€” ultimately trusted. main character trust level fr.
  • r, revoked โ€” for validity only: the key or the user ID has been revoked.
  • ?, err โ€” the program encountered an unknown trust value.

FILES ๐Ÿ—‚๏ธ

There are a few configuration files that control certain aspects of gpg's operation. Unless noted, they're expected in the current home directory (see: [option --homedir]).

config files

  • gpg.conf โ€” this is the standard configuration file read by gpg on startup. It may contain any valid long option; the leading two dashes may not be entered and the option may not be abbreviated. This default name may be changed on the command line (see: [gpg-option --options]). You should backup this file. ๐Ÿซถ
  • common.conf โ€” this is an optional configuration file read by gpg on startup. It may contain options pertaining to all components of GnuPG. Its current main use is for the "use-keyboxd" option. If the default home directory ~/.gnupg does not exist, GnuPG creates this directory and a common.conf file with "use-keyboxd".
๐Ÿ’ก Note that on larger installations, it is useful to put predefined files into the directory /etc/skel/.gnupg so that newly created users start up with a working configuration. For existing users a small helper script is provided to create these files (see: [addgnupghome]).

the internal files

For internal purposes gpg creates and maintains a few other files; they all live in the current home directory (see: [option --homedir]). Only the gpg program may modify these files โ€” hands off, bestie, I mean it. ๐Ÿ™ˆ

  • ~/.gnupg โ€” this is the default home directory which is used if neither the environment variable GNUPGHOME nor the option --homedir is given.
  • ~/.gnupg/pubring.gpg โ€” the public keyring using a legacy format. You should backup this file. If this file is not available, gpg defaults to the new keybox format and creates a file pubring.kbx unless that file already exists in which case that file will also be used for OpenPGP keys. Note that in the case that both files, pubring.gpg and pubring.kbx exists but the latter has no OpenPGP keys, the legacy file pubring.gpg will be used. Take care: GnuPG versions before 2.1 will always use the file pubring.gpg because they do not know about the new keybox format. In the case that you have to use GnuPG 1.4 to decrypt archived data you should keep this file.
  • ~/.gnupg/pubring.gpg.lock โ€” the lock file for the public keyring.
  • ~/.gnupg/pubring.kbx โ€” the public keyring using the new keybox format. This file is shared with gpgsm. You should backup this file. See above for the relation between this file and it predecessor. To convert an existing pubring.gpg file to the keybox format, you first backup the ownertrust values, then rename pubring.gpg to publickeys.backup, so it won't be recognized by any GnuPG version, run import, and finally restore the ownertrust values:
         $ cd ~/.gnupg
         $ gpg --export-ownertrust >otrust.lst
         $ mv pubring.gpg publickeys.backup
         $ gpg --import-options restore --import publickeys.backup
         $ gpg --import-ownertrust otrust.lst
  • ~/.gnupg/pubring.kbx.lock โ€” the lock file for pubring.kbx.
  • ~/.gnupg/secring.gpg โ€” the legacy secret keyring as used by GnuPG versions before 2.1. It is not used by GnuPG 2.1 and later. You may want to keep it in case you have to use GnuPG 1.4 to decrypt archived data.
  • ~/.gnupg/secring.gpg.lock โ€” the lock file for the legacy secret keyring.
  • ~/.gnupg/.gpg-v21-migrated โ€” file indicating that a migration to GnuPG 2.1 has been done.
  • ~/.gnupg/trustdb.gpg โ€” the trust database. There is no need to backup this file; it is better to backup the ownertrust values (see: [option --export-ownertrust]).
  • ~/.gnupg/trustdb.gpg.lock โ€” the lock file for the trust database.
  • ~/.gnupg/random_seed โ€” a file used to preserve the state of the internal random pool.
  • ~/.gnupg/openpgp-revocs.d/ โ€” this is the directory where gpg stores pre-generated revocation certificates. The file name corresponds to the OpenPGP fingerprint of the respective key. It is suggested to backup those certificates and if the primary private key is not stored on the disk to move them to an external storage device. Anyone who can access these files is able to revoke the corresponding key. ๐Ÿ˜ญ You may want to print them out. You should backup all files in this directory and take care to keep this backup closed away.

environment variables ๐ŸŒˆ

Operation is further controlled by a few environment variables:

  • HOME โ€” used to locate the default home directory.
  • GNUPGHOME โ€” if set, directory used instead of "~/.gnupg".
  • GPG_AGENT_INFO โ€” this variable is obsolete; it was used by GnuPG versions before 2.1. ๐Ÿ’€
  • PINENTRY_USER_DATA โ€” this value is passed via gpg-agent to pinentry. It is useful to convey extra information to a custom pinentry.
  • COLUMNS, LINES โ€” used to size some displays to the full size of the screen.
  • LANGUAGE โ€” apart from its use by GNU, it is used in the W32 version to override the language selection done through the Registry. If used and set to a valid and available language name (langid), the file with the translation is loaded from gpgdir/gnupg.nls/langid.mo. Here gpgdir is the directory out of which the gpg binary has been loaded. If it can't be loaded the Registry is tried and as last resort the native Windows locale system is used.
  • GNUPG_BUILD_ROOT โ€” this variable is only used by the regression test suite as a helper under operating systems without proper support to figure out the name of a process' text file.
  • GNUPG_EXEC_DEBUG_FLAGS โ€” this variable allows one to enable diagnostics for process management. A numeric decimal value is expected. Bit 0 enables general diagnostics, bit 1 enables certain warnings on Windows.

When calling the gpg-agent component gpg sends a set of environment variables to gpg-agent. The names of these variables can be listed using the command:

           gpg-connect-agent 'getinfo std_env_names' /bye | awk '$1=="D" {print $2}'

NOTES ๐Ÿฆ‹

gpg is often used as a backend engine by other software, she's a workhorse like that. To help with this a machine interface has been defined to have an unambiguous way to do this. The options --status-fd and --batch are almost always required for this.

Programmatic use of GnuPG

Please consider using GPGME instead of calling gpg directly. GPGME offers a stable, backend-independent interface for many cryptographic operations. It supports OpenPGP and S/MIME, and also allows interaction with various GnuPG components.

GPGME provides a C-API, and comes with bindings for C++, Qt, and Python. Bindings for other languages are available. ๐Ÿ‘‘

Ephemeral home directories

okay so sometimes you wanna contain the effects of some operation โ€” like you want to import a key to inspect it but you do NOT want that key added to your keyring, ya know? In earlier versions of GnuPG, you could specify alternate keyring files for both public and secret keys. But in modern GnuPG versions, we changed how secret keys are stored to better protect secret key material, and it wasn't possible to preserve that interface. ๐Ÿ’…

The preferred way to do this is to use ephemeral home directories. This technique works across all versions of GnuPG, no cap. โœจ

So you create a temporary directory, create (or copy) a configuration that meets your needs, then make gpg use this directory either by setting the environment variable GNUPGHOME or by using the --homedir option. GPGME supports this too on a per-context basis by modifying the engine info of contexts. Now you can execute whatever operation you like โ€” import and export key material as necessary. Once you're finished, you can just delete the directory. All GnuPG backend services that were started will detect this and shut down. ๐Ÿซถ

The quick key manipulation interface ๐ŸŽ€

Recent versions of GnuPG have an interface to manipulate keys without using the interactive command --edit-key. This interface was added mainly for the benefit of GPGME (please consider using GPGME โ€” see the manual subsection Programmatic use of GnuPG''). This interface is described in the subsection How to manage your keys''. It's giving efficient, honestly. ๐Ÿ”ฅ

Unattended key generation ๐ŸŒธ

The command --generate-key can be used together with the option --batch for unattended key generation. This is the most flexible way of generating keys, but it's also the most complex one. ngl, consider using the quick key manipulation interface described in the previous subsection ``The quick key manipulation interface''. It's way easier, bestie. ๐Ÿ˜ญ

The parameters for the key are either read from stdin or given as a file on the command line. The format of the parameter file is like this: text only, line length is limited to about 1000 characters. UTF-8 encoding must be used to specify non-ASCII characters. Empty lines are ignored. Leading and trailing white space is ignored. A hash sign as the first non-white-space character indicates a comment line. Control statements are indicated by a leading percent sign โ€” their arguments are separated by white space from the keyword. Parameters are specified by a keyword followed by a colon; arguments are separated by white space. The first parameter must be Key-Type, but control statements may be placed anywhere. The order of the parameters doesn't matter except for Key-Type. The parameters are only used for the generated keyblock (primary and subkeys); parameters from previous sets are not used. Some syntax checks may be performed. Key commences when either the end of the parameter file is reached, the next Key-Type parameter is encountered, or the control statement %commit is encountered. Periodt. ๐Ÿ’…

Control statements ๐Ÿ“

  • %echo text โ€” prints text as a diagnostic. It's like a little echo, get it? ๐Ÿฆ‹
  • %dry-run โ€” suppresses actual key generation (useful for syntax checking). No keys generated, just vibes. โœจ
  • %commit โ€” performs the key generation. Note that an implicit commit is done at the next parameter. (There's a double space in the original manpage after โ€œnextโ€ but we're not about that life.) ๐ŸŽฏ
  • %pubring filename โ€” do NOT write the key to the default or commandline-given keyring, but to filename. This must be given before the first commit to take place; duplicate specification of the same filename is ignored, and the last filename before a commit is used. The filename is used until a new filename is used (at commit points), and all keys are written to that file. If a new filename is given, this file is created (and overwrites an existing one). โš ๏ธ See the previous subsection ``Ephemeral home directories'' for a more robust way to contain side-effects. (Lowkey safer, fr fr.) ๐Ÿ›Ÿ
  • %secring filename โ€” this option is a no-op for GnuPG 2.1 and later. ๐Ÿ’€ See the previous subsection ``Ephemeral home directories''. (Yeah, don't bother.) ๐Ÿ™ˆ
  • %ask-passphrase, %no-ask-passphrase โ€” this option is a no-op since GnuPG version 2.1. So just ignore it, bestie. ๐Ÿ˜Œ
  • %no-protection โ€” using this option allows the creation of keys without any passphrase protection. This option is mainly intended for regression tests. No passphrase, no protection โ€” kinda risky but okay for tests. ๐Ÿ˜ฌ
  • %transient-key โ€” if given, the keys are created using a faster and somewhat less secure random number generator. This option may be used for keys which are only used for a short time and do not require full cryptographic strength. It only takes effect if used together with the control statement %no-protection. So like, temporary keys for temporary vibes. โณ

General Parameters ๐ŸŽ€

  • Key-Type: algo โ€” starts a new parameter block by giving the type of the primary key. The algorithm must be capable of signing. This is a required parameter. algo may either be an OpenPGP algorithm number or a string with the algorithm name. The special value default may be used for algo to create the default key type; in this case a Key-Usage shall not be given and default also be used for Subkey-Type. Slay. ๐Ÿ”‘
  • Key-Length: nbits โ€” the requested length of the generated key in bits. The default is returned by running the command gpg --gpgconf-list. For ECC keys this parameter is ignored. ๐Ÿ“
  • Key-Curve: curve โ€” the requested elliptic curve of the generated key. This is a required parameter for ECC keys. It is ignored for non-ECC keys. ๐ŸŒ€
  • Key-Grip: hexstring โ€” this is optional and used to generate a CSR or certificate for an already existing key. Key-Length will be ignored when given. ๐Ÿค
  • Key-Usage: usage-list โ€” space or comma delimited list of key usages. Allowed values are encrypt, sign, and auth. This is used to generate the key flags. Please make sure that the algorithm is capable of this usage. Note that OpenPGP requires that all primary keys are capable of certification, so no matter what usage is given here, the cert flag will be on. If no Key-Usage is specified and the Key-Type is not default, all allowed usages for that particular algorithm are used; if it is not given but default is used the usage will be sign. So yeah, cert is always on, periodt. โœ…
  • Subkey-Type: algo โ€” this generates a secondary key (subkey). Currently only one subkey can be handled. See also Key-Type above. One subkey at a time, bestie. ๐ŸŽฏ
  • Subkey-Length: nbits โ€” length of the secondary key (subkey) in bits. The default is returned by running the command gpg --gpgconf-list. ๐Ÿ“
  • Subkey-Curve: curve โ€” key curve for a subkey; similar to Key-Curve. ๐ŸŒˆ
  • Subkey-Usage: usage-list โ€” key usage lists for a subkey; similar to Key-Usage. โœจ
  • Passphrase: string โ€” if you want to specify a passphrase for the secret key, enter it here. Default is to use the Pinentry dialog to ask for a passphrase. So you can hardcode it or let Pinentry pop up. Your choice. ๐Ÿ”
  • Name-Real: name, Name-Comment: comment, Name-Email: email โ€” the three parts of a user name. Remember to use UTF-8 encoding here. If you don't give any of them, no user ID is created. So like, it's optional but you probably want it. ๐Ÿชช
  • Expire-Date: iso-date|(number[d|w|m|y]) โ€” set the expiration date for the key (and the subkey). It may either be entered in ISO date format (e.g. "20000815T145012") or as number of days, weeks, months, or years after the creation date. The special notation "seconds=N" is also allowed to specify a number of seconds since creation. Without a letter, days are assumed. Note that there is NO check done on the overflow of the type used by OpenPGP for timestamps. Thus you better make sure that the given value makes sense. Although OpenPGP works with time intervals, GnuPG uses an absolute value internally and thus the last year we can represent is 2105. So don't put a crazy number, okay? โฐ
  • Creation-Date: iso-date โ€” set the creation date of the key as stored in the key information and which is also part of the fingerprint calculation. Either a date like "1986-04-26" or a full timestamp like "19860426T042640" may be used. The time is considered to be UTC. The special notation "seconds=N" may be used to directly specify a the number of seconds since Epoch (Unix time). If it is not given the current time is used. (Yes, there's a typo โ€œa theโ€ in the original โ€” we're keeping it for authenticity. ๐Ÿ˜…)
  • Preferences: string โ€” set the cipher, hash, and compression preference values for this key. This expects the same type of string as the sub-command setpref in the --edit-key menu. ๐ŸŽ›๏ธ
  • Revoker: algo:fpr [sensitive] โ€” add a designated revoker to the generated key. Algo is the public key algorithm of the designated revoker (i.e. RSA=1, DSA=17, etc.). fpr is the fingerprint of the designated revoker. fpr may not contain spaces or colons. The optional sensitive flag marks the designated revoker as sensitive information. Only v4 and v5 keys may be designated revokers. So v4 and v5 only, bestie. ๐Ÿšซ
  • Keyserver: string โ€” this is an optional parameter that specifies the preferred keyserver URL for the key. ๐ŸŒ
  • Handle: string โ€” this is an optional parameter only used with the status lines KEY_CREATED and KEY_NOT_CREATED. string may be up to 100 characters and should not contain spaces. It is useful for batch key generation to associate a key parameter block with a status line. ๐Ÿท๏ธ

Here's an example of how to create a key in an ephemeral home directory โ€” like, look at this cuteness: ๐ŸŽ€

$ export GNUPGHOME="$(mktemp -d)"
$ cat >foo <<EOF
     %echo Generating a basic OpenPGP key
     Key-Type: DSA
     Key-Length: 1024
     Subkey-Type: ELG-E
     Subkey-Length: 1024
     Name-Real: Joe Tester
     Name-Comment: with stupid passphrase
     Name-Email: joe@foo.bar
     Expire-Date: 0
     Passphrase: abc
     # Do a commit here, so that we can later print "done" :-)
     %commit
     %echo done
EOF
$ gpg --batch --generate-key foo
 [...]
$ gpg --list-secret-keys
/tmp/tmp.0NQxB74PEf/pubring.kbx
-------------------------------
sec   dsa1024 2016-12-16 [SCA]
      768E895903FC1C44045C8CB95EEBDB71E9E849D0
uid           [ultimate] Joe Tester (with stupid passphrase) <joe@foo.bar>
ssb   elg1024 2016-12-16 [E]

okay so if you want to create a key with the default algorithms, youโ€™d use these parameters, bestie:

%echo Generating a default key
Key-Type: default
Subkey-Type: default
Name-Real: Joe Tester
Name-Comment: with stupid passphrase
Name-Email: joe@foo.bar
Expire-Date: 0
Passphrase: abc
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done

๐Ÿ› BUGS ๐Ÿ›

real talk: on older systems this program should be installed as setuid(root). this is necessary to lock memory pages. locking memory pages prevents the operating system from writing memory pages (which may contain passphrases or other sensitive material) to disk. if you get no warning message about insecure memory, your operating system supports locking without being root. the program drops root privileges as soon as locked memory is allocated. ๐Ÿ’…

also note that some systems (especially laptops) have the ability to โ€œsuspend to diskโ€ (also known as โ€œsafe sleepโ€ or โ€œhibernateโ€). this writes all memory to disk before going into a low power or even powered off mode. unless measures are taken in the operating system to protect the saved memory, passphrases or other sensitive material may be recoverable from it later. ๐Ÿ˜ญ thatโ€™s not a vibe โ€” protect your secrets.

before you report a bug, you should first search the mailing list archives for similar problems, and second check whether such a bug has already been reported to the bug tracker at https://bugs.gnupg.org. ๐Ÿซถ

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

the full documentation for this tool is maintained as a Texinfo manual. if GnuPG and the info program are properly installed at your site, the command

info gnupg

should give you access to the complete manual including a menu structure and an index. โœจ


and thatโ€™s the whole iconic page, bestie โ€” GnuPG 2.4.9, dated 2025-02-19, the one and only GPG(1) ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from