Imported Upstream version 2.1.8
[platform/upstream/gpg2.git] / doc / gpg.texi
1 @c Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2 @c               2008, 2009, 2010 Free Software Foundation, Inc.
3 @c This is part of the GnuPG manual.
4 @c For copying conditions, see the file gnupg.texi.
5
6 @include defs.inc
7
8 @node Invoking GPG
9 @chapter Invoking GPG
10 @cindex GPG command options
11 @cindex command options
12 @cindex options, GPG command
13
14 @macro gpgname
15 gpg2
16 @end macro
17 @manpage gpg2.1
18 @ifset manverb
19 .B gpg2
20 \- OpenPGP encryption and signing tool
21 @end ifset
22
23 @mansect synopsis
24 @ifset manverb
25 .B  gpg2
26 .RB [ \-\-homedir
27 .IR dir ]
28 .RB [ \-\-options
29 .IR file ]
30 .RI [ options ]
31 .I command
32 .RI [ args ]
33 @end ifset
34
35
36 @mansect description
37 @command{@gpgname} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It
38 is a tool to provide digital encryption and signing services using the
39 OpenPGP standard. @command{@gpgname} features complete key management and
40 all bells and whistles you can expect from a decent OpenPGP
41 implementation.
42
43 In contrast to the standalone command gpg from GnuPG 1.x, which is
44 might be better suited for server and embedded platforms, the 2.x
45 version is commonly installed under the name @command{gpg2} and
46 targeted to the desktop as it requires several other modules to be
47 installed.
48
49 @manpause
50 The old 1.x version will be kept maintained and it is possible to
51 install both versions on the same system.  Documentation for the old
52 GnuPG 1.x command is available as a man page and at
53 @inforef{Top,GnuPG 1,gpg}.
54
55 @xref{Option Index}, for an index to @command{@gpgname}'s commands and options.
56 @mancont
57
58 @menu
59 * GPG Commands::            List of all commands.
60 * GPG Options::             List of all options.
61 * GPG Configuration::       Configuration files.
62 * GPG Examples::            Some usage examples.
63
64 Developer information:
65 * Unattended Usage of GPG:: Using @command{gpg} from other programs.
66 @end menu
67
68 @c * GPG Protocol::        The protocol the server mode uses.
69
70
71 @c *******************************************
72 @c ***************            ****************
73 @c ***************  COMMANDS  ****************
74 @c ***************            ****************
75 @c *******************************************
76 @mansect commands
77 @node GPG Commands
78 @section Commands
79
80 Commands are not distinguished from options except for the fact that
81 only one command is allowed.
82
83 @command{@gpgname} may be run with no commands, in which case it will
84 perform a reasonable action depending on the type of file it is given
85 as input (an encrypted message is decrypted, a signature is verified,
86 a file containing keys is listed).
87
88 Please remember that option as well as command parsing stops as soon as
89 a non-option is encountered, you can explicitly stop parsing by
90 using the special option @option{--}.
91
92
93 @menu
94 * General GPG Commands::        Commands not specific to the functionality.
95 * Operational GPG Commands::    Commands to select the type of operation.
96 * OpenPGP Key Management::      How to manage your keys.
97 @end menu
98
99
100 @c *******************************************
101 @c **********  GENERAL COMMANDS  *************
102 @c *******************************************
103 @node General GPG Commands
104 @subsection Commands not specific to the function
105
106 @table @gnupgtabopt
107 @item --version
108 @opindex version
109 Print the program version and licensing information.  Note that you
110 cannot abbreviate this command.
111
112 @item --help
113 @itemx -h
114 @opindex help
115 Print a usage message summarizing the most useful command line options.
116 Note that you cannot abbreviate this command.
117
118 @item --warranty
119 @opindex warranty
120 Print warranty information.
121
122 @item --dump-options
123 @opindex dump-options
124 Print a list of all available options and commands.  Note that you cannot
125 abbreviate this command.
126 @end table
127
128
129 @c *******************************************
130 @c ********  OPERATIONAL COMMANDS  ***********
131 @c *******************************************
132 @node Operational GPG Commands
133 @subsection Commands to select the type of operation
134
135
136 @table @gnupgtabopt
137
138 @item --sign
139 @itemx -s
140 @opindex sign
141 Make a signature. This command may be combined with @option{--encrypt}
142 (for a signed and encrypted message), @option{--symmetric} (for a
143 signed and symmetrically encrypted message), or @option{--encrypt} and
144 @option{--symmetric} together (for a signed message that may be
145 decrypted via a secret key or a passphrase).  The key to be used for
146 signing is chosen by default or can be set with the
147 @option{--local-user} and @option{--default-key} options.
148
149 @item --clearsign
150 @opindex clearsign
151 Make a clear text signature.  The content in a clear text signature is
152 readable without any special software. OpenPGP software is only needed
153 to verify the signature.  Clear text signatures may modify end-of-line
154 whitespace for platform independence and are not intended to be
155 reversible.  The key to be used for signing is chosen by default or
156 can be set with the @option{--local-user} and @option{--default-key}
157 options.
158
159
160 @item --detach-sign
161 @itemx -b
162 @opindex detach-sign
163 Make a detached signature.
164
165 @item --encrypt
166 @itemx -e
167 @opindex encrypt
168 Encrypt data. This option may be combined with @option{--sign} (for a
169 signed and encrypted message), @option{--symmetric} (for a message that
170 may be decrypted via a secret key or a passphrase), or @option{--sign}
171 and @option{--symmetric} together (for a signed message that may be
172 decrypted via a secret key or a passphrase).
173
174 @item --symmetric
175 @itemx -c
176 @opindex symmetric
177 Encrypt with a symmetric cipher using a passphrase. The default
178 symmetric cipher used is @value{GPGSYMENCALGO}, but may be chosen with the
179 @option{--cipher-algo} option. This option may be combined with
180 @option{--sign} (for a signed and symmetrically encrypted message),
181 @option{--encrypt} (for a message that may be decrypted via a secret key
182 or a passphrase), or @option{--sign} and @option{--encrypt} together
183 (for a signed message that may be decrypted via a secret key or a
184 passphrase).
185
186 @item --store
187 @opindex store
188 Store only (make a simple RFC1991 literal data packet).
189
190 @item --decrypt
191 @itemx -d
192 @opindex decrypt
193 Decrypt the file given on the command line (or STDIN if no file
194 is specified) and write it to STDOUT (or the file specified with
195 @option{--output}). If the decrypted file is signed, the signature is also
196 verified. This command differs from the default operation, as it never
197 writes to the filename which is included in the file and it rejects
198 files which don't begin with an encrypted message.
199
200 @item --verify
201 @opindex verify
202 Assume that the first argument is a signed file and verify it without
203 generating any output.  With no arguments, the signature packet is
204 read from STDIN.  If only a one argument is given, it is expected to
205 be a complete signature.
206
207 With more than 1 argument, the first should be a detached signature
208 and the remaining files ake up the the signed data. To read the signed
209 data from STDIN, use @samp{-} as the second filename.  For security
210 reasons a detached signature cannot read the signed material from
211 STDIN without denoting it in the above way.
212
213 Note: If the option @option{--batch} is not used, @command{@gpgname}
214 may assume that a single argument is a file with a detached signature
215 and it will try to find a matching data file by stripping certain
216 suffixes.  Using this historical feature to verify a detached
217 signature is strongly discouraged; always specify the data file too.
218
219 Note: When verifying a cleartext signature, @command{gpg} verifies
220 only what makes up the cleartext signed data and not any extra data
221 outside of the cleartext signature or header lines following directly
222 the dash marker line.  The option @code{--output} may be used to write
223 out the actual signed data; but there are other pitfalls with this
224 format as well.  It is suggested to avoid cleartext signatures in
225 favor of detached signatures.
226
227 @item --multifile
228 @opindex multifile
229 This modifies certain other commands to accept multiple files for
230 processing on the command line or read from STDIN with each filename on
231 a separate line. This allows for many files to be processed at
232 once. @option{--multifile} may currently be used along with
233 @option{--verify}, @option{--encrypt}, and @option{--decrypt}. Note that
234 @option{--multifile --verify} may not be used with detached signatures.
235
236 @item --verify-files
237 @opindex verify-files
238 Identical to @option{--multifile --verify}.
239
240 @item --encrypt-files
241 @opindex encrypt-files
242 Identical to @option{--multifile --encrypt}.
243
244 @item --decrypt-files
245 @opindex decrypt-files
246 Identical to @option{--multifile --decrypt}.
247
248 @item --list-keys
249 @itemx -k
250 @itemx --list-public-keys
251 @opindex list-keys
252 List all keys from the public keyrings, or just the keys given on the
253 command line.
254
255 Avoid using the output of this command in scripts or other programs as
256 it is likely to change as GnuPG changes. See @option{--with-colons} for a
257 machine-parseable key listing command that is appropriate for use in
258 scripts and other programs.
259
260 @item --list-secret-keys
261 @itemx -K
262 @opindex list-secret-keys
263 List all keys from the secret keyrings, or just the ones given on the
264 command line. A @code{#} after the letters @code{sec} means that the
265 secret key is not usable (for example, if it was created via
266 @option{--export-secret-subkeys}).
267
268 @item --list-sigs
269 @opindex list-sigs
270 Same as @option{--list-keys}, but the signatures are listed too.
271 This command has the same effect as
272 using @option{--list-keys} with @option{--with-sig-list}.
273
274 For each signature listed, there are several flags in between the "sig"
275 tag and keyid. These flags give additional information about each
276 signature. From left to right, they are the numbers 1-3 for certificate
277 check level (see @option{--ask-cert-level}), "L" for a local or
278 non-exportable signature (see @option{--lsign-key}), "R" for a
279 nonRevocable signature (see the @option{--edit-key} command "nrsign"),
280 "P" for a signature that contains a policy URL (see
281 @option{--cert-policy-url}), "N" for a signature that contains a
282 notation (see @option{--cert-notation}), "X" for an eXpired signature
283 (see @option{--ask-cert-expire}), and the numbers 1-9 or "T" for 10 and
284 above to indicate trust signature levels (see the @option{--edit-key}
285 command "tsign").
286
287 @item --check-sigs
288 @opindex check-sigs
289 Same as @option{--list-sigs}, but the signatures are verified.  Note
290 that for performance reasons the revocation status of a signing key is
291 not shown.
292 This command has the same effect as
293 using @option{--list-keys} with @option{--with-sig-check}.
294
295 The status of the verification is indicated by a flag directly following
296 the "sig" tag (and thus before the flags described above for
297 @option{--list-sigs}).  A "!" indicates that the signature has been
298 successfully verified, a "-" denotes a bad signature and a "%" is used
299 if an error occurred while checking the signature (e.g. a non supported
300 algorithm).
301
302 @item --locate-keys
303 @opindex locate-keys
304 Locate the keys given as arguments.  This command basically uses the
305 same algorithm as used when locating keys for encryption or signing and
306 may thus be used to see what keys @command{@gpgname} might use.  In
307 particular external methods as defined by @option{--auto-key-locate} may
308 be used to locate a key.  Only public keys are listed.
309
310 @item --fingerprint
311 @opindex fingerprint
312 List all keys (or the specified ones) along with their
313 fingerprints. This is the same output as @option{--list-keys} but with
314 the additional output of a line with the fingerprint. May also be
315 combined with @option{--list-sigs} or @option{--check-sigs}.  If this
316 command is given twice, the fingerprints of all secondary keys are
317 listed too.
318
319 @item --list-packets
320 @opindex list-packets
321 List only the sequence of packets. This is mainly useful for
322 debugging.  When used with option @option{--verbose} the actual MPI
323 values are dumped and not only their lengths.
324
325
326 @item --card-edit
327 @opindex card-edit
328 Present a menu to work with a smartcard. The subcommand "help" provides
329 an overview on available commands. For a detailed description, please
330 see the Card HOWTO at
331 https://gnupg.org/documentation/howtos.html#GnuPG-cardHOWTO .
332
333 @item --card-status
334 @opindex card-status
335 Show the content of the smart card.
336
337 @item --change-pin
338 @opindex change-pin
339 Present a menu to allow changing the PIN of a smartcard. This
340 functionality is also available as the subcommand "passwd" with the
341 @option{--card-edit} command.
342
343 @item --delete-keys @code{name}
344 @itemx --delete-keys @code{name}
345 Remove key from the public keyring. In batch mode either @option{--yes} is
346 required or the key must be specified by fingerprint. This is a
347 safeguard against accidental deletion of multiple keys.
348
349 @item --delete-secret-keys @code{name}
350 @opindex delete-secret-keys
351 Remove key from the secret keyring. In batch mode the key
352 must be specified by fingerprint.
353
354 @item --delete-secret-and-public-key @code{name}
355 @opindex delete-secret-and-public-key
356 Same as @option{--delete-key}, but if a secret key exists, it will be
357 removed first. In batch mode the key must be specified by fingerprint.
358
359 @item --export
360 @opindex export
361 Either export all keys from all keyrings (default keyrings and those
362 registered via option @option{--keyring}), or if at least one name is given,
363 those of the given name. The exported keys are written to STDOUT or to the
364 file given with option @option{--output}.  Use together with
365 @option{--armor} to mail those keys.
366
367 @item --send-keys @code{key IDs}
368 @opindex send-keys
369 Similar to @option{--export} but sends the keys to a keyserver.
370 Fingerprints may be used instead of key IDs. Option @option{--keyserver}
371 must be used to give the name of this keyserver. Don't send your
372 complete keyring to a keyserver --- select only those keys which are new
373 or changed by you.  If no key IDs are given, @command{gpg} does nothing.
374
375 @item --export-secret-keys
376 @itemx --export-secret-subkeys
377 @opindex export-secret-keys
378 @opindex export-secret-subkeys
379 Same as @option{--export}, but exports the secret keys instead.  The
380 exported keys are written to STDOUT or to the file given with option
381 @option{--output}.  This command is often used along with the option
382 @option{--armor} to allow easy printing of the key for paper backup;
383 however the external tool @command{paperkey} does a better job for
384 creating backups on paper.  Note that exporting a secret key can be a
385 security risk if the exported keys are send over an insecure channel.
386
387 The second form of the command has the special property to render the
388 secret part of the primary key useless; this is a GNU extension to
389 OpenPGP and other implementations can not be expected to successfully
390 import such a key.  Its intended use is to generated a full key with
391 an additional signing subkey on a dedicated machine and then using
392 this command to export the key without the primary key to the main
393 machine.
394
395 GnuPG may ask you to enter the passphrase for the key.  This is
396 required because the internal protection method of the secret key is
397 different from the one specified by the OpenPGP protocol.
398
399 @item --import
400 @itemx --fast-import
401 @opindex import
402 Import/merge keys. This adds the given keys to the
403 keyring. The fast version is currently just a synonym.
404
405 There are a few other options which control how this command works.
406 Most notable here is the @option{--import-options merge-only} option
407 which does not insert new keys but does only the merging of new
408 signatures, user-IDs and subkeys.
409
410 @item --recv-keys @code{key IDs}
411 @opindex recv-keys
412 Import the keys with the given key IDs from a keyserver. Option
413 @option{--keyserver} must be used to give the name of this keyserver.
414
415 @item --refresh-keys
416 @opindex refresh-keys
417 Request updates from a keyserver for keys that already exist on the
418 local keyring. This is useful for updating a key with the latest
419 signatures, user IDs, etc. Calling this with no arguments will refresh
420 the entire keyring. Option @option{--keyserver} must be used to give the
421 name of the keyserver for all keys that do not have preferred keyservers
422 set (see @option{--keyserver-options honor-keyserver-url}).
423
424 @item --search-keys @code{names}
425 @opindex search-keys
426 Search the keyserver for the given names. Multiple names given here will
427 be joined together to create the search string for the keyserver.
428 Option @option{--keyserver} must be used to give the name of this
429 keyserver.  Keyservers that support different search methods allow using
430 the syntax specified in "How to specify a user ID" below. Note that
431 different keyserver types support different search methods. Currently
432 only LDAP supports them all.
433
434 @item --fetch-keys @code{URIs}
435 @opindex fetch-keys
436 Retrieve keys located at the specified URIs. Note that different
437 installations of GnuPG may support different protocols (HTTP, FTP,
438 LDAP, etc.)
439
440 @item --update-trustdb
441 @opindex update-trustdb
442 Do trust database maintenance. This command iterates over all keys and
443 builds the Web of Trust. This is an interactive command because it may
444 have to ask for the "ownertrust" values for keys. The user has to give
445 an estimation of how far she trusts the owner of the displayed key to
446 correctly certify (sign) other keys. GnuPG only asks for the ownertrust
447 value if it has not yet been assigned to a key. Using the
448 @option{--edit-key} menu, the assigned value can be changed at any time.
449
450 @item --check-trustdb
451 @opindex check-trustdb
452 Do trust database maintenance without user interaction. From time to
453 time the trust database must be updated so that expired keys or
454 signatures and the resulting changes in the Web of Trust can be
455 tracked. Normally, GnuPG will calculate when this is required and do it
456 automatically unless @option{--no-auto-check-trustdb} is set. This
457 command can be used to force a trust database check at any time. The
458 processing is identical to that of @option{--update-trustdb} but it
459 skips keys with a not yet defined "ownertrust".
460
461 For use with cron jobs, this command can be used together with
462 @option{--batch} in which case the trust database check is done only if
463 a check is needed. To force a run even in batch mode add the option
464 @option{--yes}.
465
466 @anchor{option --export-ownertrust}
467 @item --export-ownertrust
468 @opindex export-ownertrust
469 Send the ownertrust values to STDOUT. This is useful for backup purposes
470 as these values are the only ones which can't be re-created from a
471 corrupted trustdb.  Example:
472 @c man:.RS
473 @example
474   @gpgname{} --export-ownertrust > otrust.txt
475 @end example
476 @c man:.RE
477
478
479 @item --import-ownertrust
480 @opindex import-ownertrust
481 Update the trustdb with the ownertrust values stored in @code{files} (or
482 STDIN if not given); existing values will be overwritten.  In case of a
483 severely damaged trustdb and if you have a recent backup of the
484 ownertrust values (e.g. in the file @file{otrust.txt}, you may re-create
485 the trustdb using these commands:
486 @c man:.RS
487 @example
488   cd ~/.gnupg
489   rm trustdb.gpg
490   @gpgname{} --import-ownertrust < otrust.txt
491 @end example
492 @c man:.RE
493
494
495 @item --rebuild-keydb-caches
496 @opindex rebuild-keydb-caches
497 When updating from version 1.0.6 to 1.0.7 this command should be used
498 to create signature caches in the keyring. It might be handy in other
499 situations too.
500
501 @item --print-md @code{algo}
502 @itemx --print-mds
503 @opindex print-md
504 Print message digest of algorithm ALGO for all given files or STDIN.
505 With the second form (or a deprecated "*" as algo) digests for all
506 available algorithms are printed.
507
508 @item --gen-random @code{0|1|2} @code{count}
509 @opindex gen-random
510 Emit @var{count} random bytes of the given quality level 0, 1 or 2. If
511 @var{count} is not given or zero, an endless sequence of random bytes
512 will be emitted.  If used with @option{--armor} the output will be
513 base64 encoded.  PLEASE, don't use this command unless you know what
514 you are doing; it may remove precious entropy from the system!
515
516 @item --gen-prime @code{mode}  @code{bits}
517 @opindex gen-prime
518 Use the source, Luke :-). The output format is still subject to change.
519
520
521 @item --enarmor
522 @item --dearmor
523 @opindex enarmor
524 @opindex dearmor
525 Pack or unpack an arbitrary input into/from an OpenPGP ASCII armor.
526 This is a GnuPG extension to OpenPGP and in general not very useful.
527
528
529 @c @item --server
530 @c @opindex server
531 @c Run gpg in server mode.  This feature is not yet ready for use and
532 @c thus not documented.
533
534 @end table
535
536
537 @c *******************************************
538 @c *******  KEY MANGEMENT COMMANDS  **********
539 @c *******************************************
540 @node OpenPGP Key Management
541 @subsection How to manage your keys
542
543 This section explains the main commands for key management
544
545 @table @gnupgtabopt
546
547 @item --quick-gen-key @code{user-id}
548 @opindex quick-gen-key
549 This is a simple command to generate a standard key with one user id.
550 In contrast to @option{--gen-key} the key is generated directly
551 without the need to answer a bunch of prompts.  Unless the option
552 @option{--yes} is given, the key creation will be canceled if the
553 given user id already exists in the key ring.
554
555 If invoked directly on the console without any special options an
556 answer to a ``Continue?'' style confirmation prompt is required.  In
557 case the user id already exists in the key ring a second prompt to
558 force the creation of the key will show up.
559
560 If this command is used with @option{--batch},
561 @option{--pinentry-mode} has been set to @code{loopback}, and one of
562 the passphrase options (@option{--passphrase},
563 @option{--passphrase-fd}, or @option{passphrase-file}) is used, the
564 supplied passphrase is used for the new key and the agent does not ask
565 for it.  To create a key without any protection @code{--passphrase ''}
566 may be used.
567
568 @item --gen-key
569 @opindex gen-key
570 Generate a new key pair using the current default parameters.  This is
571 the standard command to create a new key.
572
573 @item --full-gen-key
574 @opindex gen-key
575 Generate a new key pair with dialogs for all options.  This is an
576 extended version of @option{--gen-key}.
577
578 There is also a feature which allows you to create keys in batch
579 mode. See the the manual section ``Unattended key generation'' on how
580 to use this.
581
582 @item --gen-revoke @code{name}
583 @opindex gen-revoke
584 Generate a revocation certificate for the complete key. To revoke
585 a subkey or a signature, use the @option{--edit} command.
586
587 @item --desig-revoke @code{name}
588 @opindex desig-revoke
589 Generate a designated revocation certificate for a key. This allows a
590 user (with the permission of the keyholder) to revoke someone else's
591 key.
592
593
594 @item --edit-key
595 @opindex edit-key
596 Present a menu which enables you to do most of the key management
597 related tasks.  It expects the specification of a key on the command
598 line.
599
600 @c ******** Begin Edit-key Options **********
601 @table @asis
602
603   @item uid @code{n}
604   @opindex keyedit:uid
605   Toggle selection of user ID or photographic user ID with index @code{n}.
606   Use @code{*} to select all and @code{0} to deselect all.
607
608   @item key @code{n}
609   @opindex keyedit:key
610   Toggle selection of subkey with index @code{n}.
611   Use @code{*} to select all and @code{0} to deselect all.
612
613   @item sign
614   @opindex keyedit:sign
615   Make a signature on key of user @code{name} If the key is not yet
616   signed by the default user (or the users given with -u), the program
617   displays the information of the key again, together with its
618   fingerprint and asks whether it should be signed. This question is
619   repeated for all users specified with
620   -u.
621
622   @item lsign
623   @opindex keyedit:lsign
624   Same as "sign" but the signature is marked as non-exportable and will
625   therefore never be used by others. This may be used to make keys
626   valid only in the local environment.
627
628   @item nrsign
629   @opindex keyedit:nrsign
630   Same as "sign" but the signature is marked as non-revocable and can
631   therefore never be revoked.
632
633   @item tsign
634   @opindex keyedit:tsign
635   Make a trust signature. This is a signature that combines the notions
636   of certification (like a regular signature), and trust (like the
637   "trust" command). It is generally only useful in distinct communities
638   or groups.
639 @end table
640
641 @c man:.RS
642 Note that "l" (for local / non-exportable), "nr" (for non-revocable,
643 and "t" (for trust) may be freely mixed and prefixed to "sign" to
644 create a signature of any type desired.
645 @c man:.RE
646
647 @table @asis
648
649   @item delsig
650   @opindex keyedit:delsig
651   Delete a signature. Note that it is not possible to retract a signature,
652   once it has been send to the public (i.e. to a keyserver).  In that case
653   you better use @code{revsig}.
654
655   @item revsig
656   @opindex keyedit:revsig
657   Revoke a signature. For every signature which has been generated by
658   one of the secret keys, GnuPG asks whether a revocation certificate
659   should be generated.
660
661   @item check
662   @opindex keyedit:check
663   Check the signatures on all selected user IDs.
664
665   @item adduid
666   @opindex keyedit:adduid
667   Create an additional user ID.
668
669   @item addphoto
670   @opindex keyedit:addphoto
671   Create a photographic user ID. This will prompt for a JPEG file that
672   will be embedded into the user ID. Note that a very large JPEG will make
673   for a very large key. Also note that some programs will display your
674   JPEG unchanged (GnuPG), and some programs will scale it to fit in a
675   dialog box (PGP).
676
677   @item showphoto
678   @opindex keyedit:showphoto
679   Display the selected photographic user ID.
680
681   @item deluid
682   @opindex keyedit:deluid
683   Delete a user ID or photographic user ID.  Note that it is not
684   possible to retract a user id, once it has been send to the public
685   (i.e. to a keyserver).  In that case you better use @code{revuid}.
686
687   @item revuid
688   @opindex keyedit:revuid
689   Revoke a user ID or photographic user ID.
690
691   @item primary
692   @opindex keyedit:primary
693   Flag the current user id as the primary one, removes the primary user
694   id flag from all other user ids and sets the timestamp of all affected
695   self-signatures one second ahead. Note that setting a photo user ID
696   as primary makes it primary over other photo user IDs, and setting a
697   regular user ID as primary makes it primary over other regular user
698   IDs.
699
700   @item keyserver
701   @opindex keyedit:keyserver
702   Set a preferred keyserver for the specified user ID(s). This allows
703   other users to know where you prefer they get your key from. See
704   @option{--keyserver-options honor-keyserver-url} for more on how this
705   works.  Setting a value of "none" removes an existing preferred
706   keyserver.
707
708   @item notation
709   @opindex keyedit:notation
710   Set a name=value notation for the specified user ID(s). See
711   @option{--cert-notation} for more on how this works. Setting a value of
712   "none" removes all notations, setting a notation prefixed with a minus
713   sign (-) removes that notation, and setting a notation name (without the
714   =value) prefixed with a minus sign removes all notations with that name.
715
716   @item pref
717   @opindex keyedit:pref
718   List preferences from the selected user ID. This shows the actual
719   preferences, without including any implied preferences.
720
721   @item showpref
722   @opindex keyedit:showpref
723   More verbose preferences listing for the selected user ID. This shows
724   the preferences in effect by including the implied preferences of 3DES
725   (cipher), SHA-1 (digest), and Uncompressed (compression) if they are
726   not already included in the preference list. In addition, the
727   preferred keyserver and signature notations (if any) are shown.
728
729   @item setpref @code{string}
730   @opindex keyedit:setpref
731   Set the list of user ID preferences to @code{string} for all (or just
732   the selected) user IDs. Calling setpref with no arguments sets the
733   preference list to the default (either built-in or set via
734   @option{--default-preference-list}), and calling setpref with "none"
735   as the argument sets an empty preference list. Use @command{@gpgname
736   --version} to get a list of available algorithms. Note that while you
737   can change the preferences on an attribute user ID (aka "photo ID"),
738   GnuPG does not select keys via attribute user IDs so these preferences
739   will not be used by GnuPG.
740
741   When setting preferences, you should list the algorithms in the order
742   which you'd like to see them used by someone else when encrypting a
743   message to your key.  If you don't include 3DES, it will be
744   automatically added at the end.  Note that there are many factors that
745   go into choosing an algorithm (for example, your key may not be the
746   only recipient), and so the remote OpenPGP application being used to
747   send to you may or may not follow your exact chosen order for a given
748   message.  It will, however, only choose an algorithm that is present
749   on the preference list of every recipient key.  See also the
750   INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS section below.
751
752   @item addkey
753   @opindex keyedit:addkey
754   Add a subkey to this key.
755
756   @item addcardkey
757   @opindex keyedit:addcardkey
758   Generate a subkey on a card and add it to this key.
759
760   @item keytocard
761   @opindex keyedit:keytocard
762   Transfer the selected secret subkey (or the primary key if no subkey
763   has been selected) to a smartcard. The secret key in the keyring will
764   be replaced by a stub if the key could be stored successfully on the
765   card and you use the save command later. Only certain key types may be
766   transferred to the card. A sub menu allows you to select on what card
767   to store the key. Note that it is not possible to get that key back
768   from the card - if the card gets broken your secret key will be lost
769   unless you have a backup somewhere.
770
771   @item bkuptocard @code{file}
772   @opindex keyedit:bkuptocard
773   Restore the given file to a card. This command may be used to restore a
774   backup key (as generated during card initialization) to a new card. In
775   almost all cases this will be the encryption key. You should use this
776   command only with the corresponding public key and make sure that the
777   file given as argument is indeed the backup to restore. You should then
778   select 2 to restore as encryption key.  You will first be asked to enter
779   the passphrase of the backup key and then for the Admin PIN of the card.
780
781   @item delkey
782   @opindex keyedit:delkey
783   Remove a subkey (secondary key). Note that it is not possible to retract
784   a subkey, once it has been send to the public (i.e. to a keyserver).  In
785   that case you better use @code{revkey}.
786
787   @item revkey
788   @opindex keyedit:revkey
789   Revoke a subkey.
790
791   @item expire
792   @opindex keyedit:expire
793   Change the key or subkey expiration time. If a subkey is selected, the
794   expiration time of this subkey will be changed. With no selection, the
795   key expiration of the primary key is changed.
796
797   @item trust
798   @opindex keyedit:trust
799   Change the owner trust value for the key. This updates the trust-db
800   immediately and no save is required.
801
802   @item disable
803   @itemx enable
804   @opindex keyedit:disable
805   @opindex keyedit:enable
806   Disable or enable an entire key. A disabled key can not normally be
807   used for encryption.
808
809   @item addrevoker
810   @opindex keyedit:addrevoker
811   Add a designated revoker to the key. This takes one optional argument:
812   "sensitive". If a designated revoker is marked as sensitive, it will
813   not be exported by default (see export-options).
814
815   @item passwd
816   @opindex keyedit:passwd
817   Change the passphrase of the secret key.
818
819   @item toggle
820   @opindex keyedit:toggle
821   This is dummy command which exists only for backward compatibility.
822
823   @item clean
824   @opindex keyedit:clean
825   Compact (by removing all signatures except the selfsig) any user ID
826   that is no longer usable (e.g. revoked, or expired). Then, remove any
827   signatures that are not usable by the trust calculations.
828   Specifically, this removes any signature that does not validate, any
829   signature that is superseded by a later signature, revoked signatures,
830   and signatures issued by keys that are not present on the keyring.
831
832   @item minimize
833   @opindex keyedit:minimize
834   Make the key as small as possible. This removes all signatures from
835   each user ID except for the most recent self-signature.
836
837   @item cross-certify
838   @opindex keyedit:cross-certify
839   Add cross-certification signatures to signing subkeys that may not
840   currently have them. Cross-certification signatures protect against a
841   subtle attack against signing subkeys. See
842   @option{--require-cross-certification}.  All new keys generated have
843   this signature by default, so this option is only useful to bring
844   older keys up to date.
845
846   @item save
847   @opindex keyedit:save
848   Save all changes to the key rings and quit.
849
850   @item quit
851   @opindex keyedit:quit
852   Quit the program without updating the
853   key rings.
854 @end table
855
856 @c man:.RS
857 The listing shows you the key with its secondary keys and all user
858 ids.  The primary user id is indicated by a dot, and selected keys or
859 user ids are indicated by an asterisk.  The trust
860 value is displayed with the primary key: the first is the assigned owner
861 trust and the second is the calculated trust value. Letters are used for
862 the values:
863 @c man:.RE
864
865 @table @asis
866
867   @item -
868   No ownertrust assigned / not yet calculated.
869
870   @item e
871   Trust
872   calculation has failed; probably due to an expired key.
873
874   @item q
875   Not enough information for calculation.
876
877   @item n
878   Never trust this key.
879
880   @item m
881   Marginally trusted.
882
883   @item f
884   Fully trusted.
885
886   @item u
887   Ultimately trusted.
888
889 @end table
890 @c ******** End Edit-key Options **********
891
892 @item --sign-key @code{name}
893 @opindex sign-key
894 Signs a public key with your secret key. This is a shortcut version of
895 the subcommand "sign" from @option{--edit}.
896
897 @item --lsign-key @code{name}
898 @opindex lsign-key
899 Signs a public key with your secret key but marks it as
900 non-exportable. This is a shortcut version of the subcommand "lsign"
901 from @option{--edit-key}.
902
903 @item --quick-sign-key @code{fpr} [@code{names}]
904 @itemx --quick-lsign-key @code{fpr} [@code{names}]
905 @opindex quick-sign-key
906 @opindex quick-lsign-key
907 Directly sign a key from the passphrase without any further user
908 interaction.  The @code{fpr} must be the verified primary fingerprint
909 of a key in the local keyring. If no @code{names} are given, all
910 useful user ids are signed; with given [@code{names}] only useful user
911 ids matching one of theses names are signed.  The command
912 @option{--quick-lsign-key} marks the signatures as non-exportable.  If
913 such a non-exportable signature already exists the
914 @option{--quick-sign-key} turns it into a exportable signature.
915
916 This command uses reasonable defaults and thus does not provide the
917 full flexibility of the "sign" subcommand from @option{--edit-key}.
918 Its intended use is to help unattended key signing by utilizing a list
919 of verified fingerprints.
920
921 @item --quick-adduid  @var{user-id} @var{new-user-id}
922 @opindex quick-adduid
923 This command adds a new user id to an existing key.  In contrast to
924 the interactive sub-command @code{adduid} of @option{--edit-key} the
925 @var{new-user-id} is added verbatim with only leading and trailing
926 white space removed, it is expected to be UTF-8 encoded, and no checks
927 on its form are applied.
928
929 @item --passwd @var{user_id}
930 @opindex passwd
931 Change the passphrase of the secret key belonging to the certificate
932 specified as @var{user_id}.  This is a shortcut for the sub-command
933 @code{passwd} of the edit key menu.
934
935 @end table
936
937
938 @c *******************************************
939 @c ***************            ****************
940 @c ***************  OPTIONS   ****************
941 @c ***************            ****************
942 @c *******************************************
943 @mansect options
944 @node GPG Options
945 @section Option Summary
946
947 @command{@gpgname} features a bunch of options to control the exact
948 behaviour and to change the default configuration.
949
950 @menu
951 * GPG Configuration Options::   How to change the configuration.
952 * GPG Key related Options::     Key related options.
953 * GPG Input and Output::        Input and Output.
954 * OpenPGP Options::             OpenPGP protocol specific options.
955 * Compliance Options::          Compliance options.
956 * GPG Esoteric Options::        Doing things one usually don't want to do.
957 * Deprecated Options::          Deprecated options.
958 @end menu
959
960 Long options can be put in an options file (default
961 "~/.gnupg/gpg.conf"). Short option names will not work - for example,
962 "armor" is a valid option for the options file, while "a" is not. Do not
963 write the 2 dashes, but simply the name of the option and any required
964 arguments. Lines with a hash ('#') as the first non-white-space
965 character are ignored. Commands may be put in this file too, but that is
966 not generally useful as the command will execute automatically with
967 every execution of gpg.
968
969 Please remember that option parsing stops as soon as a non-option is
970 encountered, you can explicitly stop parsing by using the special option
971 @option{--}.
972
973 @c *******************************************
974 @c ********  CONFIGURATION OPTIONS  **********
975 @c *******************************************
976 @node GPG Configuration Options
977 @subsection How to change the configuration
978
979 These options are used to change the configuration and are usually found
980 in the option file.
981
982 @table @gnupgtabopt
983
984 @item --default-key @var{name}
985 @opindex default-key
986 Use @var{name} as the default key to sign with. If this option is not
987 used, the default key is the first key found in the secret keyring.
988 Note that @option{-u} or @option{--local-user} overrides this option.
989
990 @item --default-recipient @var{name}
991 @opindex default-recipient
992 Use @var{name} as default recipient if option @option{--recipient} is
993 not used and don't ask if this is a valid one. @var{name} must be
994 non-empty.
995
996 @item --default-recipient-self
997 @opindex default-recipient-self
998 Use the default key as default recipient if option @option{--recipient} is not
999 used and don't ask if this is a valid one. The default key is the first
1000 one from the secret keyring or the one set with @option{--default-key}.
1001
1002 @item --no-default-recipient
1003 @opindex no-default-recipient
1004 Reset @option{--default-recipient} and @option{--default-recipient-self}.
1005
1006 @item -v, --verbose
1007 @opindex verbose
1008 Give more information during processing. If used
1009 twice, the input data is listed in detail.
1010
1011 @item --no-verbose
1012 @opindex no-verbose
1013 Reset verbose level to 0.
1014
1015 @item -q, --quiet
1016 @opindex quiet
1017 Try to be as quiet as possible.
1018
1019 @item --batch
1020 @itemx --no-batch
1021 @opindex batch
1022 @opindex no-batch
1023 Use batch mode.  Never ask, do not allow interactive commands.
1024 @option{--no-batch} disables this option.  Note that even with a
1025 filename given on the command line, gpg might still need to read from
1026 STDIN (in particular if gpg figures that the input is a
1027 detached signature and no data file has been specified).  Thus if you
1028 do not want to feed data via STDIN, you should connect STDIN to
1029 @file{/dev/null}.
1030
1031 @item --no-tty
1032 @opindex no-tty
1033 Make sure that the TTY (terminal) is never used for any output.
1034 This option is needed in some cases because GnuPG sometimes prints
1035 warnings to the TTY even if @option{--batch} is used.
1036
1037 @item --yes
1038 @opindex yes
1039 Assume "yes" on most questions.
1040
1041 @item --no
1042 @opindex no
1043 Assume "no" on most questions.
1044
1045
1046 @item --list-options @code{parameters}
1047 @opindex list-options
1048 This is a space or comma delimited string that gives options used when
1049 listing keys and signatures (that is, @option{--list-keys},
1050 @option{--list-sigs}, @option{--list-public-keys},
1051 @option{--list-secret-keys}, and the @option{--edit-key} functions).
1052 Options can be prepended with a @option{no-} (after the two dashes) to
1053 give the opposite meaning.  The options are:
1054
1055 @table @asis
1056
1057   @item show-photos
1058   @opindex list-options:show-photos
1059   Causes @option{--list-keys}, @option{--list-sigs},
1060   @option{--list-public-keys}, and @option{--list-secret-keys} to
1061   display any photo IDs attached to the key.  Defaults to no. See also
1062   @option{--photo-viewer}.  Does not work with @option{--with-colons}:
1063   see @option{--attribute-fd} for the appropriate way to get photo data
1064   for scripts and other frontends.
1065
1066   @item show-usage
1067   @opindex list-options:show-usage
1068   Show usage information for keys and subkeys in the standard key
1069   listing.  This is a list of letters indicating the allowed usage for a
1070   key (@code{E}=encryption, @code{S}=signing, @code{C}=certification,
1071   @code{A}=authentication).  Defaults to no.
1072
1073   @item show-policy-urls
1074   @opindex list-options:show-policy-urls
1075   Show policy URLs in the @option{--list-sigs} or @option{--check-sigs}
1076   listings.  Defaults to no.
1077
1078   @item show-notations
1079   @itemx show-std-notations
1080   @itemx show-user-notations
1081   @opindex list-options:show-notations
1082   @opindex list-options:show-std-notations
1083   @opindex list-options:show-user-notations
1084   Show all, IETF standard, or user-defined signature notations in the
1085   @option{--list-sigs} or @option{--check-sigs} listings. Defaults to no.
1086
1087   @item show-keyserver-urls
1088   @opindex list-options:show-keyserver-urls
1089   Show any preferred keyserver URL in the @option{--list-sigs} or
1090   @option{--check-sigs} listings. Defaults to no.
1091
1092   @item show-uid-validity
1093   @opindex list-options:show-uid-validity
1094   Display the calculated validity of user IDs during key listings.
1095   Defaults to no.
1096
1097   @item show-unusable-uids
1098   @opindex list-options:show-unusable-uids
1099   Show revoked and expired user IDs in key listings. Defaults to no.
1100
1101   @item show-unusable-subkeys
1102   @opindex list-options:show-unusable-subkeys
1103   Show revoked and expired subkeys in key listings. Defaults to no.
1104
1105   @item show-keyring
1106   @opindex list-options:show-keyring
1107   Display the keyring name at the head of key listings to show which
1108   keyring a given key resides on. Defaults to no.
1109
1110   @item show-sig-expire
1111   @opindex list-options:show-sig-expire
1112   Show signature expiration dates (if any) during @option{--list-sigs} or
1113   @option{--check-sigs} listings. Defaults to no.
1114
1115   @item show-sig-subpackets
1116   @opindex list-options:show-sig-subpackets
1117   Include signature subpackets in the key listing. This option can take an
1118   optional argument list of the subpackets to list. If no argument is
1119   passed, list all subpackets. Defaults to no. This option is only
1120   meaningful when using @option{--with-colons} along with
1121   @option{--list-sigs} or @option{--check-sigs}.
1122
1123 @end table
1124
1125 @item --verify-options @code{parameters}
1126 @opindex verify-options
1127 This is a space or comma delimited string that gives options used when
1128 verifying signatures. Options can be prepended with a `no-' to give
1129 the opposite meaning. The options are:
1130
1131 @table @asis
1132
1133   @item show-photos
1134   @opindex verify-options:show-photos
1135   Display any photo IDs present on the key that issued the signature.
1136   Defaults to no. See also @option{--photo-viewer}.
1137
1138   @item show-policy-urls
1139   @opindex verify-options:show-policy-urls
1140   Show policy URLs in the signature being verified. Defaults to no.
1141
1142   @item show-notations
1143   @itemx show-std-notations
1144   @itemx show-user-notations
1145   @opindex verify-options:show-notations
1146   @opindex verify-options:show-std-notations
1147   @opindex verify-options:show-user-notations
1148   Show all, IETF standard, or user-defined signature notations in the
1149   signature being verified. Defaults to IETF standard.
1150
1151   @item show-keyserver-urls
1152   @opindex verify-options:show-keyserver-urls
1153   Show any preferred keyserver URL in the signature being verified.
1154   Defaults to no.
1155
1156   @item show-uid-validity
1157   @opindex verify-options:show-uid-validity
1158   Display the calculated validity of the user IDs on the key that issued
1159   the signature. Defaults to no.
1160
1161   @item show-unusable-uids
1162   @opindex verify-options:show-unusable-uids
1163   Show revoked and expired user IDs during signature verification.
1164   Defaults to no.
1165
1166   @item show-primary-uid-only
1167   @opindex verify-options:show-primary-uid-only
1168   Show only the primary user ID during signature verification.  That is
1169   all the AKA lines as well as photo Ids are not shown with the signature
1170   verification status.
1171
1172   @item pka-lookups
1173   @opindex verify-options:pka-lookups
1174   Enable PKA lookups to verify sender addresses. Note that PKA is based
1175   on DNS, and so enabling this option may disclose information on when
1176   and what signatures are verified or to whom data is encrypted. This
1177   is similar to the "web bug" described for the auto-key-retrieve
1178   feature.
1179
1180   @item pka-trust-increase
1181   @opindex verify-options:pka-trust-increase
1182   Raise the trust in a signature to full if the signature passes PKA
1183   validation. This option is only meaningful if pka-lookups is set.
1184 @end table
1185
1186 @item --enable-large-rsa
1187 @itemx --disable-large-rsa
1188 @opindex enable-large-rsa
1189 @opindex disable-large-rsa
1190 With --gen-key and --batch, enable the creation of larger RSA secret
1191 keys than is generally recommended (up to 8192 bits).  These large
1192 keys are more expensive to use, and their signatures and
1193 certifications are also larger.
1194
1195 @item --enable-dsa2
1196 @itemx --disable-dsa2
1197 @opindex enable-dsa2
1198 @opindex disable-dsa2
1199 Enable hash truncation for all DSA keys even for old DSA Keys up to
1200 1024 bit.  This is also the default with @option{--openpgp}.  Note
1201 that older versions of GnuPG also required this flag to allow the
1202 generation of DSA larger than 1024 bit.
1203
1204 @item --photo-viewer @code{string}
1205 @opindex photo-viewer
1206 This is the command line that should be run to view a photo ID. "%i"
1207 will be expanded to a filename containing the photo. "%I" does the
1208 same, except the file will not be deleted once the viewer exits.
1209 Other flags are "%k" for the key ID, "%K" for the long key ID, "%f"
1210 for the key fingerprint, "%t" for the extension of the image type
1211 (e.g. "jpg"), "%T" for the MIME type of the image (e.g. "image/jpeg"),
1212 "%v" for the single-character calculated validity of the image being
1213 viewed (e.g. "f"), "%V" for the calculated validity as a string (e.g.
1214 "full"), "%U" for a base32 encoded hash of the user ID,
1215 and "%%" for an actual percent sign. If neither %i or %I are present,
1216 then the photo will be supplied to the viewer on standard input.
1217
1218 The default viewer is "xloadimage -fork -quiet -title 'KeyID 0x%k'
1219 STDIN". Note that if your image viewer program is not secure, then
1220 executing it from GnuPG does not make it secure.
1221
1222 @item --exec-path @code{string}
1223 @opindex exec-path
1224 Sets a list of directories to search for photo viewers and keyserver
1225 helpers. If not provided, keyserver helpers use the compiled-in
1226 default directory, and photo viewers use the $PATH environment
1227 variable.
1228 Note, that on W32 system this value is ignored when searching for
1229 keyserver helpers.
1230
1231 @item --keyring @code{file}
1232 @opindex keyring
1233 Add @code{file} to the current list of keyrings. If @code{file} begins
1234 with a tilde and a slash, these are replaced by the $HOME directory. If
1235 the filename does not contain a slash, it is assumed to be in the GnuPG
1236 home directory ("~/.gnupg" if @option{--homedir} or $GNUPGHOME is not
1237 used).
1238
1239 Note that this adds a keyring to the current list. If the intent is to
1240 use the specified keyring alone, use @option{--keyring} along with
1241 @option{--no-default-keyring}.
1242
1243 @item --secret-keyring @code{file}
1244 @opindex secret-keyring
1245 This is an obsolete option and ignored.  All secret keys are stored in
1246 the @file{private-keys-v1.d} directory below the GnuPG home directory.
1247
1248 @item --primary-keyring @code{file}
1249 @opindex primary-keyring
1250 Designate @code{file} as the primary public keyring. This means that
1251 newly imported keys (via @option{--import} or keyserver
1252 @option{--recv-from}) will go to this keyring.
1253
1254 @item --trustdb-name @code{file}
1255 @opindex trustdb-name
1256 Use @code{file} instead of the default trustdb. If @code{file} begins
1257 with a tilde and a slash, these are replaced by the $HOME directory. If
1258 the filename does not contain a slash, it is assumed to be in the GnuPG
1259 home directory (@file{~/.gnupg} if @option{--homedir} or $GNUPGHOME is
1260 not used).
1261
1262 @include opt-homedir.texi
1263
1264
1265 @item --display-charset @code{name}
1266 @opindex display-charset
1267 Set the name of the native character set. This is used to convert
1268 some informational strings like user IDs to the proper UTF-8 encoding.
1269 Note that this has nothing to do with the character set of data to be
1270 encrypted or signed; GnuPG does not recode user-supplied data. If
1271 this option is not used, the default character set is determined from
1272 the current locale. A verbosity level of 3 shows the chosen set.
1273 Valid values for @code{name} are:
1274
1275 @table @asis
1276
1277   @item iso-8859-1
1278   @opindex display-charset:iso-8859-1
1279   This is the Latin 1 set.
1280
1281   @item iso-8859-2
1282   @opindex display-charset:iso-8859-2
1283   The Latin 2 set.
1284
1285   @item iso-8859-15
1286   @opindex display-charset:iso-8859-15
1287   This is currently an alias for
1288   the Latin 1 set.
1289
1290   @item koi8-r
1291   @opindex display-charset:koi8-r
1292   The usual Russian set (rfc1489).
1293
1294   @item utf-8
1295   @opindex display-charset:utf-8
1296   Bypass all translations and assume
1297   that the OS uses native UTF-8 encoding.
1298 @end table
1299
1300 @item --utf8-strings
1301 @itemx --no-utf8-strings
1302 @opindex utf8-strings
1303 Assume that command line arguments are given as UTF8 strings. The
1304 default (@option{--no-utf8-strings}) is to assume that arguments are
1305 encoded in the character set as specified by
1306 @option{--display-charset}. These options affect all following
1307 arguments. Both options may be used multiple times.
1308
1309 @anchor{gpg-option --options}
1310 @item --options @code{file}
1311 @opindex options
1312 Read options from @code{file} and do not try to read them from the
1313 default options file in the homedir (see @option{--homedir}). This
1314 option is ignored if used in an options file.
1315
1316 @item --no-options
1317 @opindex no-options
1318 Shortcut for @option{--options /dev/null}. This option is detected
1319 before an attempt to open an option file.  Using this option will also
1320 prevent the creation of a @file{~/.gnupg} homedir.
1321
1322 @item -z @code{n}
1323 @itemx --compress-level @code{n}
1324 @itemx --bzip2-compress-level @code{n}
1325 @opindex compress-level
1326 @opindex bzip2-compress-level
1327 Set compression level to @code{n} for the ZIP and ZLIB compression
1328 algorithms. The default is to use the default compression level of zlib
1329 (normally 6). @option{--bzip2-compress-level} sets the compression level
1330 for the BZIP2 compression algorithm (defaulting to 6 as well). This is a
1331 different option from @option{--compress-level} since BZIP2 uses a
1332 significant amount of memory for each additional compression level.
1333 @option{-z} sets both. A value of 0 for @code{n} disables compression.
1334
1335 @item --bzip2-decompress-lowmem
1336 @opindex bzip2-decompress-lowmem
1337 Use a different decompression method for BZIP2 compressed files. This
1338 alternate method uses a bit more than half the memory, but also runs
1339 at half the speed. This is useful under extreme low memory
1340 circumstances when the file was originally compressed at a high
1341 @option{--bzip2-compress-level}.
1342
1343
1344 @item --mangle-dos-filenames
1345 @itemx --no-mangle-dos-filenames
1346 @opindex mangle-dos-filenames
1347 @opindex no-mangle-dos-filenames
1348 Older version of Windows cannot handle filenames with more than one
1349 dot. @option{--mangle-dos-filenames} causes GnuPG to replace (rather
1350 than add to) the extension of an output filename to avoid this
1351 problem. This option is off by default and has no effect on non-Windows
1352 platforms.
1353
1354 @item --ask-cert-level
1355 @itemx --no-ask-cert-level
1356 @opindex ask-cert-level
1357 When making a key signature, prompt for a certification level. If this
1358 option is not specified, the certification level used is set via
1359 @option{--default-cert-level}. See @option{--default-cert-level} for
1360 information on the specific levels and how they are
1361 used. @option{--no-ask-cert-level} disables this option. This option
1362 defaults to no.
1363
1364 @item --default-cert-level @code{n}
1365 @opindex default-cert-level
1366 The default to use for the check level when signing a key.
1367
1368 0 means you make no particular claim as to how carefully you verified
1369 the key.
1370
1371 1 means you believe the key is owned by the person who claims to own
1372 it but you could not, or did not verify the key at all. This is
1373 useful for a "persona" verification, where you sign the key of a
1374 pseudonymous user.
1375
1376 2 means you did casual verification of the key. For example, this
1377 could mean that you verified the key fingerprint and checked the
1378 user ID on the key against a photo ID.
1379
1380 3 means you did extensive verification of the key. For example, this
1381 could mean that you verified the key fingerprint with the owner of the
1382 key in person, and that you checked, by means of a hard to forge
1383 document with a photo ID (such as a passport) that the name of the key
1384 owner matches the name in the user ID on the key, and finally that you
1385 verified (by exchange of email) that the email address on the key
1386 belongs to the key owner.
1387
1388 Note that the examples given above for levels 2 and 3 are just that:
1389 examples. In the end, it is up to you to decide just what "casual"
1390 and "extensive" mean to you.
1391
1392 This option defaults to 0 (no particular claim).
1393
1394 @item --min-cert-level
1395 @opindex min-cert-level
1396 When building the trust database, treat any signatures with a
1397 certification level below this as invalid. Defaults to 2, which
1398 disregards level 1 signatures. Note that level 0 "no particular
1399 claim" signatures are always accepted.
1400
1401 @item --trusted-key @code{long key ID}
1402 @opindex trusted-key
1403 Assume that the specified key (which must be given
1404 as a full 8 byte key ID) is as trustworthy as one of
1405 your own secret keys. This option is useful if you
1406 don't want to keep your secret keys (or one of them)
1407 online but still want to be able to check the validity of a given
1408 recipient's or signator's key.
1409
1410 @item --trust-model @code{pgp|classic|direct|always|auto}
1411 @opindex trust-model
1412 Set what trust model GnuPG should follow. The models are:
1413
1414 @table @asis
1415
1416   @item pgp
1417   @opindex trust-mode:pgp
1418   This is the Web of Trust combined with trust signatures as used in PGP
1419   5.x and later. This is the default trust model when creating a new
1420   trust database.
1421
1422   @item classic
1423   @opindex trust-mode:classic
1424   This is the standard Web of Trust as introduced by PGP 2.
1425
1426   @item direct
1427   @opindex trust-mode:direct
1428   Key validity is set directly by the user and not calculated via the
1429   Web of Trust.
1430
1431   @item always
1432   @opindex trust-mode:always
1433   Skip key validation and assume that used keys are always fully
1434   valid. You generally won't use this unless you are using some
1435   external validation scheme. This option also suppresses the
1436   "[uncertain]" tag printed with signature checks when there is no
1437   evidence that the user ID is bound to the key.  Note that this
1438   trust model still does not allow the use of expired, revoked, or
1439   disabled keys.
1440
1441   @item auto
1442   @opindex trust-mode:auto
1443   Select the trust model depending on whatever the internal trust
1444   database says. This is the default model if such a database already
1445   exists.
1446 @end table
1447
1448 @item --auto-key-locate @code{parameters}
1449 @itemx --no-auto-key-locate
1450 @opindex auto-key-locate
1451 GnuPG can automatically locate and retrieve keys as needed using this
1452 option. This happens when encrypting to an email address (in the
1453 "user@@example.com" form), and there are no user@@example.com keys on
1454 the local keyring.  This option takes any number of the following
1455 mechanisms, in the order they are to be tried:
1456
1457 @table @asis
1458
1459   @item cert
1460   Locate a key using DNS CERT, as specified in rfc4398.
1461
1462   @item pka
1463   Locate a key using DNS PKA.
1464
1465   @item ldap
1466   Using DNS Service Discovery, check the domain in question for any LDAP
1467   keyservers to use.  If this fails, attempt to locate the key using the
1468   PGP Universal method of checking @samp{ldap://keys.(thedomain)}.
1469
1470   @item keyserver
1471   Locate a key using whatever keyserver is defined using the
1472   @option{--keyserver} option.
1473
1474   @item keyserver-URL
1475   In addition, a keyserver URL as used in the @option{--keyserver} option
1476   may be used here to query that particular keyserver.
1477
1478   @item local
1479   Locate the key using the local keyrings.  This mechanism allows to
1480   select the order a local key lookup is done.  Thus using
1481   @samp{--auto-key-locate local} is identical to
1482   @option{--no-auto-key-locate}.
1483
1484   @item nodefault
1485   This flag disables the standard local key lookup, done before any of the
1486   mechanisms defined by the @option{--auto-key-locate} are tried.  The
1487   position of this mechanism in the list does not matter.  It is not
1488   required if @code{local} is also used.
1489
1490   @item clear
1491   Clear all defined mechanisms.  This is useful to override
1492   mechanisms given in a config file.
1493
1494 @end table
1495
1496 @item --keyid-format @code{short|0xshort|long|0xlong}
1497 @opindex keyid-format
1498 Select how to display key IDs. "short" is the traditional 8-character
1499 key ID. "long" is the more accurate (but less convenient)
1500 16-character key ID. Add an "0x" to either to include an "0x" at the
1501 beginning of the key ID, as in 0x99242560.  Note that this option is
1502 ignored if the option --with-colons is used.
1503
1504 @item --keyserver @code{name}
1505 @opindex keyserver
1506 Use @code{name} as your keyserver. This is the server that
1507 @option{--recv-keys}, @option{--send-keys}, and @option{--search-keys}
1508 will communicate with to receive keys from, send keys to, and search for
1509 keys on. The format of the @code{name} is a URI:
1510 `scheme:[//]keyservername[:port]' The scheme is the type of keyserver:
1511 "hkp" for the HTTP (or compatible) keyservers, "ldap" for the LDAP
1512 keyservers, or "mailto" for the Graff email keyserver. Note that your
1513 particular installation of GnuPG may have other keyserver types
1514 available as well. Keyserver schemes are case-insensitive. After the
1515 keyserver name, optional keyserver configuration options may be
1516 provided. These are the same as the global @option{--keyserver-options}
1517 from below, but apply only to this particular keyserver.
1518
1519 Most keyservers synchronize with each other, so there is generally no
1520 need to send keys to more than one server. The keyserver
1521 @code{hkp://keys.gnupg.net} uses round robin DNS to give a different
1522 keyserver each time you use it.
1523
1524 @item --keyserver-options @code{name=value}
1525 @opindex keyserver-options
1526 This is a space or comma delimited string that gives options for the
1527 keyserver. Options can be prefixed with a `no-' to give the opposite
1528 meaning. Valid import-options or export-options may be used here as
1529 well to apply to importing (@option{--recv-key}) or exporting
1530 (@option{--send-key}) a key from a keyserver. While not all options
1531 are available for all keyserver types, some common options are:
1532
1533 @table @asis
1534
1535   @item include-revoked
1536   When searching for a key with @option{--search-keys}, include keys that
1537   are marked on the keyserver as revoked. Note that not all keyservers
1538   differentiate between revoked and unrevoked keys, and for such
1539   keyservers this option is meaningless. Note also that most keyservers do
1540   not have cryptographic verification of key revocations, and so turning
1541   this option off may result in skipping keys that are incorrectly marked
1542   as revoked.
1543
1544   @item include-disabled
1545   When searching for a key with @option{--search-keys}, include keys that
1546   are marked on the keyserver as disabled. Note that this option is not
1547   used with HKP keyservers.
1548
1549   @item auto-key-retrieve
1550   This option enables the automatic retrieving of keys from a keyserver
1551   when verifying signatures made by keys that are not on the local
1552   keyring.
1553
1554   Note that this option makes a "web bug" like behavior possible.
1555   Keyserver operators can see which keys you request, so by sending you
1556   a message signed by a brand new key (which you naturally will not have
1557   on your local keyring), the operator can tell both your IP address and
1558   the time when you verified the signature.
1559
1560   @item honor-keyserver-url
1561   When using @option{--refresh-keys}, if the key in question has a preferred
1562   keyserver URL, then use that preferred keyserver to refresh the key
1563   from. In addition, if auto-key-retrieve is set, and the signature
1564   being verified has a preferred keyserver URL, then use that preferred
1565   keyserver to fetch the key from. Note that this option introduces a
1566   "web bug": The creator of the key can see when the keys is
1567   refreshed.  Thus this option is not enabled by default.
1568
1569   @item honor-pka-record
1570   If auto-key-retrieve is set, and the signature being verified has a
1571   PKA record, then use the PKA information to fetch the key. Defaults
1572   to "yes".
1573
1574   @item include-subkeys
1575   When receiving a key, include subkeys as potential targets. Note that
1576   this option is not used with HKP keyservers, as they do not support
1577   retrieving keys by subkey id.
1578
1579   @item timeout
1580   Tell the keyserver helper program how long (in seconds) to try and
1581   perform a keyserver action before giving up. Note that performing
1582   multiple actions at the same time uses this timeout value per action.
1583   For example, when retrieving multiple keys via @option{--recv-keys}, the
1584   timeout applies separately to each key retrieval, and not to the
1585   @option{--recv-keys} command as a whole. Defaults to 30 seconds.
1586
1587   @item http-proxy=@code{value}
1588   Set the proxy to use for HTTP and HKP keyservers.
1589   This overrides any proxy defined in @file{dirmngr.conf}.
1590
1591   @item verbose
1592   This option has no more function since GnuPG 2.1.  Use the
1593   @code{dirmngr} configuration options instead.
1594
1595   @item debug
1596   This option has no more function since GnuPG 2.1.  Use the
1597   @code{dirmngr} configuration options instead.
1598
1599   @item check-cert
1600   This option has no more function since GnuPG 2.1.  Use the
1601   @code{dirmngr} configuration options instead.
1602
1603   @item ca-cert-file
1604   This option has no more function since GnuPG 2.1.  Use the
1605   @code{dirmngr} configuration options instead.
1606
1607 @end table
1608
1609 @item --completes-needed @code{n}
1610 @opindex compliant-needed
1611 Number of completely trusted users to introduce a new
1612 key signer (defaults to 1).
1613
1614 @item --marginals-needed @code{n}
1615 @opindex marginals-needed
1616 Number of marginally trusted users to introduce a new
1617 key signer (defaults to 3)
1618
1619 @item --max-cert-depth @code{n}
1620 @opindex max-cert-depth
1621 Maximum depth of a certification chain (default is 5).
1622
1623 @item --no-sig-cache
1624 @opindex no-sig-cache
1625 Do not cache the verification status of key signatures.
1626 Caching gives a much better performance in key listings. However, if
1627 you suspect that your public keyring is not save against write
1628 modifications, you can use this option to disable the caching. It
1629 probably does not make sense to disable it because all kind of damage
1630 can be done if someone else has write access to your public keyring.
1631
1632 @item --auto-check-trustdb
1633 @itemx --no-auto-check-trustdb
1634 @opindex auto-check-trustdb
1635 If GnuPG feels that its information about the Web of Trust has to be
1636 updated, it automatically runs the @option{--check-trustdb} command
1637 internally.  This may be a time consuming
1638 process. @option{--no-auto-check-trustdb} disables this option.
1639
1640 @item --use-agent
1641 @itemx --no-use-agent
1642 @opindex use-agent
1643 This is dummy option. @command{@gpgname} always requires the agent.
1644
1645 @item --gpg-agent-info
1646 @opindex gpg-agent-info
1647 This is dummy option. It has no effect when used with @command{gpg2}.
1648
1649
1650 @item --agent-program @var{file}
1651 @opindex agent-program
1652 Specify an agent program to be used for secret key operations.  The
1653 default value is determined by running @command{gpgconf} with the
1654 option @option{--list-dirs}.  Note that the pipe symbol (@code{|}) is
1655 used for a regression test suite hack and may thus not be used in the
1656 file name.
1657
1658 @item --dirmngr-program @var{file}
1659 @opindex dirmngr-program
1660 Specify a dirmngr program to be used for keyserver access.  The
1661 default value is @file{@value{BINDIR}/dirmngr}.  This is only used as a
1662 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
1663 a running dirmngr cannot be connected.
1664
1665 @item --no-autostart
1666 @opindex no-autostart
1667 Do not start the gpg-agent or the dirmngr if it has not yet been
1668 started and its service is required.  This option is mostly useful on
1669 machines where the connection to gpg-agent has been redirected to
1670 another machines.  If dirmngr is required on the remote machine, it
1671 may be started manually using @command{gpgconf --launch dirmngr}.
1672
1673 @item --lock-once
1674 @opindex lock-once
1675 Lock the databases the first time a lock is requested
1676 and do not release the lock until the process
1677 terminates.
1678
1679 @item --lock-multiple
1680 @opindex lock-multiple
1681 Release the locks every time a lock is no longer
1682 needed. Use this to override a previous @option{--lock-once}
1683 from a config file.
1684
1685 @item --lock-never
1686 @opindex lock-never
1687 Disable locking entirely. This option should be used only in very
1688 special environments, where it can be assured that only one process
1689 is accessing those files. A bootable floppy with a stand-alone
1690 encryption system will probably use this. Improper usage of this
1691 option may lead to data and key corruption.
1692
1693 @item --exit-on-status-write-error
1694 @opindex exit-on-status-write-error
1695 This option will cause write errors on the status FD to immediately
1696 terminate the process. That should in fact be the default but it never
1697 worked this way and thus we need an option to enable this, so that the
1698 change won't break applications which close their end of a status fd
1699 connected pipe too early. Using this option along with
1700 @option{--enable-progress-filter} may be used to cleanly cancel long
1701 running gpg operations.
1702
1703 @item --limit-card-insert-tries @code{n}
1704 @opindex limit-card-insert-tries
1705 With @code{n} greater than 0 the number of prompts asking to insert a
1706 smartcard gets limited to N-1. Thus with a value of 1 gpg won't at
1707 all ask to insert a card if none has been inserted at startup. This
1708 option is useful in the configuration file in case an application does
1709 not know about the smartcard support and waits ad infinitum for an
1710 inserted card.
1711
1712 @item --no-random-seed-file
1713 @opindex no-random-seed-file
1714 GnuPG uses a file to store its internal random pool over invocations.
1715 This makes random generation faster; however sometimes write operations
1716 are not desired. This option can be used to achieve that with the cost of
1717 slower random generation.
1718
1719 @item --no-greeting
1720 @opindex no-greeting
1721 Suppress the initial copyright message.
1722
1723 @item --no-secmem-warning
1724 @opindex no-secmem-warning
1725 Suppress the warning about "using insecure memory".
1726
1727 @item --no-permission-warning
1728 @opindex permission-warning
1729 Suppress the warning about unsafe file and home directory (@option{--homedir})
1730 permissions. Note that the permission checks that GnuPG performs are
1731 not intended to be authoritative, but rather they simply warn about
1732 certain common permission problems. Do not assume that the lack of a
1733 warning means that your system is secure.
1734
1735 Note that the warning for unsafe @option{--homedir} permissions cannot be
1736 suppressed in the gpg.conf file, as this would allow an attacker to
1737 place an unsafe gpg.conf file in place, and use this file to suppress
1738 warnings about itself. The @option{--homedir} permissions warning may only be
1739 suppressed on the command line.
1740
1741 @item --no-mdc-warning
1742 @opindex no-mdc-warning
1743 Suppress the warning about missing MDC integrity protection.
1744
1745 @item --require-secmem
1746 @itemx --no-require-secmem
1747 @opindex require-secmem
1748 Refuse to run if GnuPG cannot get secure memory. Defaults to no
1749 (i.e. run, but give a warning).
1750
1751
1752 @item --require-cross-certification
1753 @itemx --no-require-cross-certification
1754 @opindex require-cross-certification
1755 When verifying a signature made from a subkey, ensure that the cross
1756 certification "back signature" on the subkey is present and valid.  This
1757 protects against a subtle attack against subkeys that can sign.
1758 Defaults to @option{--require-cross-certification} for
1759 @command{@gpgname}.
1760
1761 @item --expert
1762 @itemx --no-expert
1763 @opindex expert
1764 Allow the user to do certain nonsensical or "silly" things like
1765 signing an expired or revoked key, or certain potentially incompatible
1766 things like generating unusual key types. This also disables certain
1767 warning messages about potentially incompatible actions. As the name
1768 implies, this option is for experts only. If you don't fully
1769 understand the implications of what it allows you to do, leave this
1770 off. @option{--no-expert} disables this option.
1771
1772 @end table
1773
1774
1775 @c *******************************************
1776 @c ********  KEY RELATED OPTIONS  ************
1777 @c *******************************************
1778 @node GPG Key related Options
1779 @subsection Key related options
1780
1781 @table @gnupgtabopt
1782
1783 @item --recipient @var{name}
1784 @itemx -r
1785 @opindex recipient
1786 Encrypt for user id @var{name}. If this option or
1787 @option{--hidden-recipient} is not specified, GnuPG asks for the user-id
1788 unless @option{--default-recipient} is given.
1789
1790 @item --hidden-recipient @var{name}
1791 @itemx -R
1792 @opindex hidden-recipient
1793 Encrypt for user ID @var{name}, but hide the key ID of this user's
1794 key. This option helps to hide the receiver of the message and is a
1795 limited countermeasure against traffic analysis. If this option or
1796 @option{--recipient} is not specified, GnuPG asks for the user ID unless
1797 @option{--default-recipient} is given.
1798
1799 @item --encrypt-to @code{name}
1800 @opindex encrypt-to
1801 Same as @option{--recipient} but this one is intended for use in the
1802 options file and may be used with your own user-id as an
1803 "encrypt-to-self". These keys are only used when there are other
1804 recipients given either by use of @option{--recipient} or by the asked
1805 user id.  No trust checking is performed for these user ids and even
1806 disabled keys can be used.
1807
1808 @item --hidden-encrypt-to @code{name}
1809 @opindex hidden-encrypt-to
1810 Same as @option{--hidden-recipient} but this one is intended for use in the
1811 options file and may be used with your own user-id as a hidden
1812 "encrypt-to-self". These keys are only used when there are other
1813 recipients given either by use of @option{--recipient} or by the asked user id.
1814 No trust checking is performed for these user ids and even disabled
1815 keys can be used.
1816
1817 @item --no-encrypt-to
1818 @opindex no-encrypt-to
1819 Disable the use of all @option{--encrypt-to} and
1820 @option{--hidden-encrypt-to} keys.
1821
1822 @item --group @code{name=value1 }
1823 @opindex group
1824 Sets up a named group, which is similar to aliases in email programs.
1825 Any time the group name is a recipient (@option{-r} or
1826 @option{--recipient}), it will be expanded to the values
1827 specified. Multiple groups with the same name are automatically merged
1828 into a single group.
1829
1830 The values are @code{key IDs} or fingerprints, but any key description
1831 is accepted. Note that a value with spaces in it will be treated as
1832 two different values. Note also there is only one level of expansion
1833 --- you cannot make an group that points to another group. When used
1834 from the command line, it may be necessary to quote the argument to
1835 this option to prevent the shell from treating it as multiple
1836 arguments.
1837
1838 @item --ungroup @code{name}
1839 @opindex ungroup
1840 Remove a given entry from the @option{--group} list.
1841
1842 @item --no-groups
1843 @opindex no-groups
1844 Remove all entries from the @option{--group} list.
1845
1846 @item --local-user @var{name}
1847 @itemx -u
1848 @opindex local-user
1849 Use @var{name} as the key to sign with. Note that this option overrides
1850 @option{--default-key}.
1851
1852 @item --try-secret-key @var{name}
1853 @opindex try-secret-key
1854 For hidden recipients GPG needs to know the keys to use for trial
1855 decryption.  The key set with @option{--default-key} is always tried
1856 first, but this is often not sufficient.  This option allows to set more
1857 keys to be used for trial decryption.  Although any valid user-id
1858 specification may be used for @var{name} it makes sense to use at least
1859 the long keyid to avoid ambiguities.  Note that gpg-agent might pop up a
1860 pinentry for a lot keys to do the trial decryption.  If you want to stop
1861 all further trial decryption you may use close-window button instead of
1862 the cancel button.
1863
1864 @item --try-all-secrets
1865 @opindex try-all-secrets
1866 Don't look at the key ID as stored in the message but try all secret
1867 keys in turn to find the right decryption key. This option forces the
1868 behaviour as used by anonymous recipients (created by using
1869 @option{--throw-keyids} or @option{--hidden-recipient}) and might come
1870 handy in case where an encrypted message contains a bogus key ID.
1871
1872 @item --skip-hidden-recipients
1873 @itemx --no-skip-hidden-recipients
1874 @opindex skip-hidden-recipients
1875 @opindex no-skip-hidden-recipients
1876 During decryption skip all anonymous recipients.  This option helps in
1877 the case that people use the hidden recipients feature to hide there
1878 own encrypt-to key from others.  If oneself has many secret keys this
1879 may lead to a major annoyance because all keys are tried in turn to
1880 decrypt something which was not really intended for it.  The drawback
1881 of this option is that it is currently not possible to decrypt a
1882 message which includes real anonymous recipients.
1883
1884
1885 @end table
1886
1887 @c *******************************************
1888 @c ********  INPUT AND OUTPUT  ***************
1889 @c *******************************************
1890 @node GPG Input and Output
1891 @subsection Input and Output
1892
1893 @table @gnupgtabopt
1894
1895 @item --armor
1896 @itemx -a
1897 @opindex armor
1898 Create ASCII armored output.  The default is to create the binary
1899 OpenPGP format.
1900
1901 @item --no-armor
1902 @opindex no-armor
1903 Assume the input data is not in ASCII armored format.
1904
1905 @item --output @var{file}
1906 @itemx -o @var{file}
1907 @opindex output
1908 Write output to @var{file}.
1909
1910 @item --max-output @code{n}
1911 @opindex max-output
1912 This option sets a limit on the number of bytes that will be generated
1913 when processing a file. Since OpenPGP supports various levels of
1914 compression, it is possible that the plaintext of a given message may be
1915 significantly larger than the original OpenPGP message. While GnuPG
1916 works properly with such messages, there is often a desire to set a
1917 maximum file size that will be generated before processing is forced to
1918 stop by the OS limits. Defaults to 0, which means "no limit".
1919
1920 @item --import-options @code{parameters}
1921 @opindex import-options
1922 This is a space or comma delimited string that gives options for
1923 importing keys. Options can be prepended with a `no-' to give the
1924 opposite meaning. The options are:
1925
1926 @table @asis
1927
1928   @item import-local-sigs
1929   Allow importing key signatures marked as "local". This is not
1930   generally useful unless a shared keyring scheme is being used.
1931   Defaults to no.
1932
1933   @item keep-ownertrust
1934   Normally possible still existing ownertrust values of a key are
1935   cleared if a key is imported.  This is in general desirable so that
1936   a formerly deleted key does not automatically gain an ownertrust
1937   values merely due to import.  On the other hand it is sometimes
1938   necessary to re-import a trusted set of keys again but keeping
1939   already assigned ownertrust values.  This can be achived by using
1940   this option.
1941
1942   @item repair-pks-subkey-bug
1943   During import, attempt to repair the damage caused by the PKS keyserver
1944   bug (pre version 0.9.6) that mangles keys with multiple subkeys. Note
1945   that this cannot completely repair the damaged key as some crucial data
1946   is removed by the keyserver, but it does at least give you back one
1947   subkey. Defaults to no for regular @option{--import} and to yes for
1948   keyserver @option{--recv-keys}.
1949
1950   @item merge-only
1951   During import, allow key updates to existing keys, but do not allow
1952   any new keys to be imported. Defaults to no.
1953
1954   @item import-clean
1955   After import, compact (remove all signatures except the
1956   self-signature) any user IDs from the new key that are not usable.
1957   Then, remove any signatures from the new key that are not usable.
1958   This includes signatures that were issued by keys that are not present
1959   on the keyring. This option is the same as running the @option{--edit-key}
1960   command "clean" after import. Defaults to no.
1961
1962   @item import-minimal
1963   Import the smallest key possible. This removes all signatures except
1964   the most recent self-signature on each user ID. This option is the
1965   same as running the @option{--edit-key} command "minimize" after import.
1966   Defaults to no.
1967 @end table
1968
1969 @item --export-options @code{parameters}
1970 @opindex export-options
1971 This is a space or comma delimited string that gives options for
1972 exporting keys. Options can be prepended with a `no-' to give the
1973 opposite meaning. The options are:
1974
1975 @table @asis
1976
1977   @item export-local-sigs
1978   Allow exporting key signatures marked as "local". This is not
1979   generally useful unless a shared keyring scheme is being used.
1980   Defaults to no.
1981
1982   @item export-attributes
1983   Include attribute user IDs (photo IDs) while exporting. This is
1984   useful to export keys if they are going to be used by an OpenPGP
1985   program that does not accept attribute user IDs. Defaults to yes.
1986
1987   @item export-sensitive-revkeys
1988   Include designated revoker information that was marked as
1989   "sensitive". Defaults to no.
1990
1991   @c Since GnuPG 2.1 gpg-agent manages the secret key and thus the
1992   @c export-reset-subkey-passwd hack is not anymore justified.  Such use
1993   @c cases may be implemented using a specialized secret key export
1994   @c tool.
1995   @c @item export-reset-subkey-passwd
1996   @c When using the @option{--export-secret-subkeys} command, this option resets
1997   @c the passphrases for all exported subkeys to empty. This is useful
1998   @c when the exported subkey is to be used on an unattended machine where
1999   @c a passphrase doesn't necessarily make sense. Defaults to no.
2000
2001   @item export-clean
2002   Compact (remove all signatures from) user IDs on the key being
2003   exported if the user IDs are not usable. Also, do not export any
2004   signatures that are not usable. This includes signatures that were
2005   issued by keys that are not present on the keyring. This option is
2006   the same as running the @option{--edit-key} command "clean" before export
2007   except that the local copy of the key is not modified. Defaults to
2008   no.
2009
2010   @item export-minimal
2011   Export the smallest key possible. This removes all signatures except the
2012   most recent self-signature on each user ID. This option is the same as
2013   running the @option{--edit-key} command "minimize" before export except
2014   that the local copy of the key is not modified. Defaults to no.
2015 @end table
2016
2017 @item --with-colons
2018 @opindex with-colons
2019 Print key listings delimited by colons. Note that the output will be
2020 encoded in UTF-8 regardless of any @option{--display-charset} setting. This
2021 format is useful when GnuPG is called from scripts and other programs
2022 as it is easily machine parsed. The details of this format are
2023 documented in the file @file{doc/DETAILS}, which is included in the GnuPG
2024 source distribution.
2025
2026
2027 @item --print-pka-records
2028 @opindex print-pka-records
2029 Modify the output of the list commands to print PKA records suitable
2030 to put into DNS zone files.  An ORIGIN line is printed before each
2031 record to allow diverting the records to the corresponding zone file.
2032
2033 @item --fixed-list-mode
2034 @opindex fixed-list-mode
2035 Do not merge primary user ID and primary key in @option{--with-colon}
2036 listing mode and print all timestamps as seconds since 1970-01-01.
2037 Since GnuPG 2.0.10, this mode is always used and thus this option is
2038 obsolete; it does not harm to use it though.
2039
2040 @item --legacy-list-mode
2041 @opindex legacy-list-mode
2042 Revert to the pre-2.1 public key list mode.  This only affects the
2043 human readable output and not the machine interface
2044 (i.e. @code{--with-colons}).  Note that the legacy format does not
2045 allow to convey suitable information for elliptic curves.
2046
2047 @item --with-fingerprint
2048 @opindex with-fingerprint
2049 Same as the command @option{--fingerprint} but changes only the format
2050 of the output and may be used together with another command.
2051
2052 @item --with-icao-spelling
2053 @opindex with-icao-spelling
2054 Print the ICAO spelling of the fingerprint in addition to the hex digits.
2055
2056 @item --with-keygrip
2057 @opindex with-keygrip
2058 Include the keygrip in the key listings.
2059
2060 @item --with-secret
2061 @opindex with-secret
2062 Include info about the presence of a secret key in public key listings
2063 done with @code{--with-colons}.
2064
2065 @end table
2066
2067 @c *******************************************
2068 @c ********  OPENPGP OPTIONS  ****************
2069 @c *******************************************
2070 @node OpenPGP Options
2071 @subsection OpenPGP protocol specific options.
2072
2073 @table @gnupgtabopt
2074
2075 @item -t, --textmode
2076 @itemx --no-textmode
2077 @opindex textmode
2078 Treat input files as text and store them in the OpenPGP canonical text
2079 form with standard "CRLF" line endings. This also sets the necessary
2080 flags to inform the recipient that the encrypted or signed data is text
2081 and may need its line endings converted back to whatever the local
2082 system uses. This option is useful when communicating between two
2083 platforms that have different line ending conventions (UNIX-like to Mac,
2084 Mac to Windows, etc). @option{--no-textmode} disables this option, and
2085 is the default.
2086
2087 @item --force-v3-sigs
2088 @itemx --no-force-v3-sigs
2089 @item --force-v4-certs
2090 @itemx --no-force-v4-certs
2091 These options are obsolete and have no effect since GnuPG 2.1.
2092
2093 @item --force-mdc
2094 @opindex force-mdc
2095 Force the use of encryption with a modification detection code. This
2096 is always used with the newer ciphers (those with a blocksize greater
2097 than 64 bits), or if all of the recipient keys indicate MDC support in
2098 their feature flags.
2099
2100 @item --disable-mdc
2101 @opindex disable-mdc
2102 Disable the use of the modification detection code. Note that by
2103 using this option, the encrypted message becomes vulnerable to a
2104 message modification attack.
2105
2106 @item --personal-cipher-preferences @code{string}
2107 @opindex personal-cipher-preferences
2108 Set the list of personal cipher preferences to @code{string}.  Use
2109 @command{@gpgname --version} to get a list of available algorithms,
2110 and use @code{none} to set no preference at all.  This allows the user
2111 to safely override the algorithm chosen by the recipient key
2112 preferences, as GPG will only select an algorithm that is usable by
2113 all recipients.  The most highly ranked cipher in this list is also
2114 used for the @option{--symmetric} encryption command.
2115
2116 @item --personal-digest-preferences @code{string}
2117 @opindex personal-digest-preferences
2118 Set the list of personal digest preferences to @code{string}.  Use
2119 @command{@gpgname --version} to get a list of available algorithms,
2120 and use @code{none} to set no preference at all.  This allows the user
2121 to safely override the algorithm chosen by the recipient key
2122 preferences, as GPG will only select an algorithm that is usable by
2123 all recipients.  The most highly ranked digest algorithm in this list
2124 is also used when signing without encryption
2125 (e.g. @option{--clearsign} or @option{--sign}).
2126
2127 @item --personal-compress-preferences @code{string}
2128 @opindex personal-compress-preferences
2129 Set the list of personal compression preferences to @code{string}.
2130 Use @command{@gpgname --version} to get a list of available
2131 algorithms, and use @code{none} to set no preference at all.  This
2132 allows the user to safely override the algorithm chosen by the
2133 recipient key preferences, as GPG will only select an algorithm that
2134 is usable by all recipients.  The most highly ranked compression
2135 algorithm in this list is also used when there are no recipient keys
2136 to consider (e.g. @option{--symmetric}).
2137
2138 @item --s2k-cipher-algo @code{name}
2139 @opindex s2k-cipher-algo
2140 Use @code{name} as the cipher algorithm used to protect secret keys.
2141 The default cipher is @value{GPGSYMENCALGO}. This cipher is also used
2142 for symmetric encryption with a passphrase if
2143 @option{--personal-cipher-preferences} and @option{--cipher-algo} is
2144 not given.
2145
2146 @item --s2k-digest-algo @code{name}
2147 @opindex s2k-digest-algo
2148 Use @code{name} as the digest algorithm used to mangle the passphrases.
2149 The default algorithm is SHA-1.
2150
2151 @item --s2k-mode @code{n}
2152 @opindex s2k-mode
2153 Selects how passphrases are mangled. If @code{n} is 0 a plain
2154 passphrase (which is not recommended) will be used, a 1 adds a salt to
2155 the passphrase and a 3 (the default) iterates the whole process a
2156 number of times (see --s2k-count).  Unless @option{--rfc1991} is used,
2157 this mode is also used for symmetric encryption with a passphrase.
2158
2159 @item --s2k-count @code{n}
2160 @opindex s2k-count
2161 Specify how many times the passphrase mangling is repeated.  This
2162 value may range between 1024 and 65011712 inclusive.  The default is
2163 inquired from gpg-agent.  Note that not all values in the
2164 1024-65011712 range are legal and if an illegal value is selected,
2165 GnuPG will round up to the nearest legal value.  This option is only
2166 meaningful if @option{--s2k-mode} is 3.
2167
2168
2169 @end table
2170
2171 @c ***************************
2172 @c ******* Compliance ********
2173 @c ***************************
2174 @node Compliance Options
2175 @subsection Compliance options
2176
2177 These options control what GnuPG is compliant to. Only one of these
2178 options may be active at a time. Note that the default setting of
2179 this is nearly always the correct one. See the INTEROPERABILITY WITH
2180 OTHER OPENPGP PROGRAMS section below before using one of these
2181 options.
2182
2183 @table @gnupgtabopt
2184
2185 @item --gnupg
2186 @opindex gnupg
2187 Use standard GnuPG behavior. This is essentially OpenPGP behavior
2188 (see @option{--openpgp}), but with some additional workarounds for common
2189 compatibility problems in different versions of PGP. This is the
2190 default option, so it is not generally needed, but it may be useful to
2191 override a different compliance option in the gpg.conf file.
2192
2193 @item --openpgp
2194 @opindex openpgp
2195 Reset all packet, cipher and digest options to strict OpenPGP
2196 behavior. Use this option to reset all previous options like
2197 @option{--s2k-*}, @option{--cipher-algo}, @option{--digest-algo} and
2198 @option{--compress-algo} to OpenPGP compliant values. All PGP
2199 workarounds are disabled.
2200
2201 @item --rfc4880
2202 @opindex rfc4880
2203 Reset all packet, cipher and digest options to strict RFC-4880
2204 behavior. Note that this is currently the same thing as
2205 @option{--openpgp}.
2206
2207 @item --rfc2440
2208 @opindex rfc2440
2209 Reset all packet, cipher and digest options to strict RFC-2440
2210 behavior.
2211
2212 @ifclear gpgtowone
2213 @item --rfc1991
2214 @opindex rfc1991
2215 Try to be more RFC-1991 (PGP 2.x) compliant.  This option is
2216 deprecated will be removed in GnuPG 2.1.
2217
2218 @item --pgp2
2219 @opindex pgp2
2220 Set up all options to be as PGP 2.x compliant as possible, and warn if
2221 an action is taken (e.g. encrypting to a non-RSA key) that will create
2222 a message that PGP 2.x will not be able to handle. Note that `PGP
2223 2.x' here means `MIT PGP 2.6.2'. There are other versions of PGP 2.x
2224 available, but the MIT release is a good common baseline.
2225
2226 This option implies
2227 @option{--rfc1991 --disable-mdc --no-force-v4-certs
2228  --escape-from-lines  --force-v3-sigs --allow-weak-digest-algos
2229  --cipher-algo IDEA --digest-algo MD5 --compress-algo ZIP}.
2230 It also disables @option{--textmode} when encrypting.
2231
2232 This option is deprecated will be removed in GnuPG 2.1.  The reason
2233 for dropping PGP-2 support is that the PGP 2 format is not anymore
2234 considered safe (for example due to the use of the broken MD5 algorithm).
2235 Note that the decryption of PGP-2 created messages will continue to work.
2236 @end ifclear
2237
2238 @item --pgp6
2239 @opindex pgp6
2240 Set up all options to be as PGP 6 compliant as possible. This
2241 restricts you to the ciphers IDEA (if the IDEA plugin is installed),
2242 3DES, and CAST5, the hashes MD5, SHA1 and RIPEMD160, and the
2243 compression algorithms none and ZIP. This also disables
2244 --throw-keyids, and making signatures with signing subkeys as PGP 6
2245 does not understand signatures made by signing subkeys.
2246
2247 This option implies @option{--disable-mdc --escape-from-lines}.
2248
2249 @item --pgp7
2250 @opindex pgp7
2251 Set up all options to be as PGP 7 compliant as possible. This is
2252 identical to @option{--pgp6} except that MDCs are not disabled, and the
2253 list of allowable ciphers is expanded to add AES128, AES192, AES256, and
2254 TWOFISH.
2255
2256 @item --pgp8
2257 @opindex pgp8
2258 Set up all options to be as PGP 8 compliant as possible. PGP 8 is a lot
2259 closer to the OpenPGP standard than previous versions of PGP, so all
2260 this does is disable @option{--throw-keyids} and set
2261 @option{--escape-from-lines}.  All algorithms are allowed except for the
2262 SHA224, SHA384, and SHA512 digests.
2263
2264 @end table
2265
2266
2267 @c *******************************************
2268 @c ********  ESOTERIC OPTIONS  ***************
2269 @c *******************************************
2270 @node GPG Esoteric Options
2271 @subsection Doing things one usually doesn't want to do.
2272
2273 @table @gnupgtabopt
2274
2275 @item -n
2276 @itemx --dry-run
2277 @opindex dry-run
2278 Don't make any changes (this is not completely implemented).
2279
2280 @item --list-only
2281 @opindex list-only
2282 Changes the behaviour of some commands. This is like @option{--dry-run} but
2283 different in some cases. The semantic of this command may be extended in
2284 the future. Currently it only skips the actual decryption pass and
2285 therefore enables a fast listing of the encryption keys.
2286
2287 @item -i
2288 @itemx --interactive
2289 @opindex interactive
2290 Prompt before overwriting any files.
2291
2292 @item --debug-level @var{level}
2293 @opindex debug-level
2294 Select the debug level for investigating problems. @var{level} may be
2295 a numeric value or by a keyword:
2296
2297 @table @code
2298   @item none
2299   No debugging at all.  A value of less than 1 may be used instead of
2300   the keyword.
2301   @item basic
2302   Some basic debug messages.  A value between 1 and 2 may be used
2303   instead of the keyword.
2304   @item advanced
2305   More verbose debug messages.  A value between 3 and 5 may be used
2306   instead of the keyword.
2307   @item expert
2308   Even more detailed messages.  A value between 6 and 8 may be used
2309   instead of the keyword.
2310   @item guru
2311   All of the debug messages you can get. A value greater than 8 may be
2312   used instead of the keyword.  The creation of hash tracing files is
2313   only enabled if the keyword is used.
2314 @end table
2315
2316 How these messages are mapped to the actual debugging flags is not
2317 specified and may change with newer releases of this program. They are
2318 however carefully selected to best aid in debugging.
2319
2320 @item --debug @var{flags}
2321 @opindex debug
2322 Set debugging flags. All flags are or-ed and @var{flags} may be given
2323 in C syntax (e.g. 0x0042) or as a comma separated list of flag names.
2324 To get a list of all supported flags the single word "help" can be
2325 used.
2326
2327 @item --debug-all
2328 @opindex debug-all
2329 Set all useful debugging flags.
2330
2331 @item --debug-iolbf
2332 @opindex debug-iolbf
2333 Set stdout into line buffered mode.  This option is only honored when
2334 given on the command line.
2335
2336 @item --faked-system-time @var{epoch}
2337 @opindex faked-system-time
2338 This option is only useful for testing; it sets the system time back or
2339 forth to @var{epoch} which is the number of seconds elapsed since the year
2340 1970.  Alternatively @var{epoch} may be given as a full ISO time string
2341 (e.g. "20070924T154812").
2342
2343 @item --enable-progress-filter
2344 @opindex enable-progress-filter
2345 Enable certain PROGRESS status outputs. This option allows frontends
2346 to display a progress indicator while gpg is processing larger files.
2347 There is a slight performance overhead using it.
2348
2349 @item --status-fd @code{n}
2350 @opindex status-fd
2351 Write special status strings to the file descriptor @code{n}.
2352 See the file DETAILS in the documentation for a listing of them.
2353
2354 @item --status-file @code{file}
2355 @opindex status-file
2356 Same as @option{--status-fd}, except the status data is written to file
2357 @code{file}.
2358
2359 @item --logger-fd @code{n}
2360 @opindex logger-fd
2361 Write log output to file descriptor @code{n} and not to STDERR.
2362
2363 @item --log-file @code{file}
2364 @itemx --logger-file @code{file}
2365 @opindex log-file
2366 Same as @option{--logger-fd}, except the logger data is written to file
2367 @code{file}.  Note that @option{--log-file} is only implemented for
2368 GnuPG-2.
2369
2370 @item --attribute-fd @code{n}
2371 @opindex attribute-fd
2372 Write attribute subpackets to the file descriptor @code{n}. This is most
2373 useful for use with @option{--status-fd}, since the status messages are
2374 needed to separate out the various subpackets from the stream delivered
2375 to the file descriptor.
2376
2377 @item --attribute-file @code{file}
2378 @opindex attribute-file
2379 Same as @option{--attribute-fd}, except the attribute data is written to
2380 file @code{file}.
2381
2382 @item --comment @code{string}
2383 @itemx --no-comments
2384 @opindex comment
2385 Use @code{string} as a comment string in clear text signatures and ASCII
2386 armored messages or keys (see @option{--armor}). The default behavior is
2387 not to use a comment string. @option{--comment} may be repeated multiple
2388 times to get multiple comment strings. @option{--no-comments} removes
2389 all comments.  It is a good idea to keep the length of a single comment
2390 below 60 characters to avoid problems with mail programs wrapping such
2391 lines.  Note that comment lines, like all other header lines, are not
2392 protected by the signature.
2393
2394 @item --emit-version
2395 @itemx --no-emit-version
2396 @opindex emit-version
2397 Force inclusion of the version string in ASCII armored output.  If
2398 given once only the name of the program and the major number is
2399 emitted (default), given twice the minor is also emitted, given triple
2400 the micro is added, and given quad an operating system identification
2401 is also emitted.  @option{--no-emit-version} disables the version
2402 line.
2403
2404 @item --sig-notation @code{name=value}
2405 @itemx --cert-notation @code{name=value}
2406 @itemx -N, --set-notation @code{name=value}
2407 @opindex sig-notation
2408 @opindex cert-notation
2409 @opindex set-notation
2410 Put the name value pair into the signature as notation data.
2411 @code{name} must consist only of printable characters or spaces, and
2412 must contain a '@@' character in the form keyname@@domain.example.com
2413 (substituting the appropriate keyname and domain name, of course).  This
2414 is to help prevent pollution of the IETF reserved notation
2415 namespace. The @option{--expert} flag overrides the '@@'
2416 check. @code{value} may be any printable string; it will be encoded in
2417 UTF8, so you should check that your @option{--display-charset} is set
2418 correctly. If you prefix @code{name} with an exclamation mark (!), the
2419 notation data will be flagged as critical
2420 (rfc4880:5.2.3.16). @option{--sig-notation} sets a notation for data
2421 signatures. @option{--cert-notation} sets a notation for key signatures
2422 (certifications). @option{--set-notation} sets both.
2423
2424 There are special codes that may be used in notation names. "%k" will
2425 be expanded into the key ID of the key being signed, "%K" into the
2426 long key ID of the key being signed, "%f" into the fingerprint of the
2427 key being signed, "%s" into the key ID of the key making the
2428 signature, "%S" into the long key ID of the key making the signature,
2429 "%g" into the fingerprint of the key making the signature (which might
2430 be a subkey), "%p" into the fingerprint of the primary key of the key
2431 making the signature, "%c" into the signature count from the OpenPGP
2432 smartcard, and "%%" results in a single "%". %k, %K, and %f are only
2433 meaningful when making a key signature (certification), and %c is only
2434 meaningful when using the OpenPGP smartcard.
2435
2436 @item --sig-policy-url @code{string}
2437 @itemx --cert-policy-url @code{string}
2438 @itemx --set-policy-url @code{string}
2439 @opindex sig-policy-url
2440 @opindex cert-policy-url
2441 @opindex set-policy-url
2442 Use @code{string} as a Policy URL for signatures (rfc4880:5.2.3.20).  If
2443 you prefix it with an exclamation mark (!), the policy URL packet will
2444 be flagged as critical. @option{--sig-policy-url} sets a policy url for
2445 data signatures. @option{--cert-policy-url} sets a policy url for key
2446 signatures (certifications). @option{--set-policy-url} sets both.
2447
2448 The same %-expandos used for notation data are available here as well.
2449
2450 @item --sig-keyserver-url @code{string}
2451 @opindex sig-keyserver-url
2452 Use @code{string} as a preferred keyserver URL for data signatures. If
2453 you prefix it with an exclamation mark (!), the keyserver URL packet
2454 will be flagged as critical.
2455
2456 The same %-expandos used for notation data are available here as well.
2457
2458 @item --set-filename @code{string}
2459 @opindex set-filename
2460 Use @code{string} as the filename which is stored inside messages.
2461 This overrides the default, which is to use the actual filename of the
2462 file being encrypted.  Using the empty string for @var{string}
2463 effectively removes the filename from the output.
2464
2465 @item --for-your-eyes-only
2466 @itemx --no-for-your-eyes-only
2467 @opindex for-your-eyes-only
2468 Set the `for your eyes only' flag in the message. This causes GnuPG to
2469 refuse to save the file unless the @option{--output} option is given,
2470 and PGP to use a "secure viewer" with a claimed Tempest-resistant font
2471 to display the message. This option overrides @option{--set-filename}.
2472 @option{--no-for-your-eyes-only} disables this option.
2473
2474 @item --use-embedded-filename
2475 @itemx --no-use-embedded-filename
2476 @opindex use-embedded-filename
2477 Try to create a file with a name as embedded in the data. This can be
2478 a dangerous option as it allows to overwrite files. Defaults to no.
2479
2480 @item --cipher-algo @code{name}
2481 @opindex cipher-algo
2482 Use @code{name} as cipher algorithm. Running the program with the
2483 command @option{--version} yields a list of supported algorithms. If
2484 this is not used the cipher algorithm is selected from the preferences
2485 stored with the key. In general, you do not want to use this option as
2486 it allows you to violate the OpenPGP standard.
2487 @option{--personal-cipher-preferences} is the safe way to accomplish the
2488 same thing.
2489
2490 @item --digest-algo @code{name}
2491 @opindex digest-algo
2492 Use @code{name} as the message digest algorithm. Running the program
2493 with the command @option{--version} yields a list of supported algorithms. In
2494 general, you do not want to use this option as it allows you to
2495 violate the OpenPGP standard. @option{--personal-digest-preferences} is the
2496 safe way to accomplish the same thing.
2497
2498 @item --compress-algo @code{name}
2499 @opindex compress-algo
2500 Use compression algorithm @code{name}. "zlib" is RFC-1950 ZLIB
2501 compression. "zip" is RFC-1951 ZIP compression which is used by PGP.
2502 "bzip2" is a more modern compression scheme that can compress some
2503 things better than zip or zlib, but at the cost of more memory used
2504 during compression and decompression. "uncompressed" or "none"
2505 disables compression. If this option is not used, the default
2506 behavior is to examine the recipient key preferences to see which
2507 algorithms the recipient supports. If all else fails, ZIP is used for
2508 maximum compatibility.
2509
2510 ZLIB may give better compression results than ZIP, as the compression
2511 window size is not limited to 8k. BZIP2 may give even better
2512 compression results than that, but will use a significantly larger
2513 amount of memory while compressing and decompressing. This may be
2514 significant in low memory situations. Note, however, that PGP (all
2515 versions) only supports ZIP compression. Using any algorithm other
2516 than ZIP or "none" will make the message unreadable with PGP. In
2517 general, you do not want to use this option as it allows you to
2518 violate the OpenPGP standard. @option{--personal-compress-preferences} is the
2519 safe way to accomplish the same thing.
2520
2521 @item --cert-digest-algo @code{name}
2522 @opindex cert-digest-algo
2523 Use @code{name} as the message digest algorithm used when signing a
2524 key. Running the program with the command @option{--version} yields a
2525 list of supported algorithms. Be aware that if you choose an algorithm
2526 that GnuPG supports but other OpenPGP implementations do not, then some
2527 users will not be able to use the key signatures you make, or quite
2528 possibly your entire key.
2529
2530 @item --disable-cipher-algo @code{name}
2531 @opindex disable-cipher-algo
2532 Never allow the use of @code{name} as cipher algorithm.
2533 The given name will not be checked so that a later loaded algorithm
2534 will still get disabled.
2535
2536 @item --disable-pubkey-algo @code{name}
2537 @opindex disable-pubkey-algo
2538 Never allow the use of @code{name} as public key algorithm.
2539 The given name will not be checked so that a later loaded algorithm
2540 will still get disabled.
2541
2542 @item --throw-keyids
2543 @itemx --no-throw-keyids
2544 @opindex throw-keyids
2545 Do not put the recipient key IDs into encrypted messages. This helps to
2546 hide the receivers of the message and is a limited countermeasure
2547 against traffic analysis.@footnote{Using a little social engineering
2548 anyone who is able to decrypt the message can check whether one of the
2549 other recipients is the one he suspects.}  On the receiving side, it may
2550 slow down the decryption process because all available secret keys must
2551 be tried.  @option{--no-throw-keyids} disables this option. This option
2552 is essentially the same as using @option{--hidden-recipient} for all
2553 recipients.
2554
2555 @item --not-dash-escaped
2556 @opindex not-dash-escaped
2557 This option changes the behavior of cleartext signatures
2558 so that they can be used for patch files. You should not
2559 send such an armored file via email because all spaces
2560 and line endings are hashed too. You can not use this
2561 option for data which has 5 dashes at the beginning of a
2562 line, patch files don't have this. A special armor header
2563 line tells GnuPG about this cleartext signature option.
2564
2565 @item --escape-from-lines
2566 @itemx --no-escape-from-lines
2567 @opindex escape-from-lines
2568 Because some mailers change lines starting with "From " to ">From " it
2569 is good to handle such lines in a special way when creating cleartext
2570 signatures to prevent the mail system from breaking the signature. Note
2571 that all other PGP versions do it this way too.  Enabled by
2572 default. @option{--no-escape-from-lines} disables this option.
2573
2574 @item --passphrase-repeat @code{n}
2575 @opindex passphrase-repeat
2576 Specify how many times @command{@gpgname} will request a new
2577 passphrase be repeated.  This is useful for helping memorize a
2578 passphrase.  Defaults to 1 repetition.
2579
2580 @item --passphrase-fd @code{n}
2581 @opindex passphrase-fd
2582 Read the passphrase from file descriptor @code{n}. Only the first line
2583 will be read from file descriptor @code{n}. If you use 0 for @code{n},
2584 the passphrase will be read from STDIN. This can only be used if only
2585 one passphrase is supplied.
2586
2587 Note that this passphrase is only used if the option @option{--batch}
2588 has also been given.  This is different from GnuPG version 1.x.
2589
2590 @item --passphrase-file @code{file}
2591 @opindex passphrase-file
2592 Read the passphrase from file @code{file}. Only the first line will
2593 be read from file @code{file}. This can only be used if only one
2594 passphrase is supplied. Obviously, a passphrase stored in a file is
2595 of questionable security if other users can read this file. Don't use
2596 this option if you can avoid it.
2597 Note that this passphrase is only used if the option @option{--batch}
2598 has also been given.  This is different from GnuPG version 1.x.
2599
2600 @item --passphrase @code{string}
2601 @opindex passphrase
2602 Use @code{string} as the passphrase. This can only be used if only one
2603 passphrase is supplied. Obviously, this is of very questionable
2604 security on a multi-user system. Don't use this option if you can
2605 avoid it.
2606 Note that this passphrase is only used if the option @option{--batch}
2607 has also been given.  This is different from GnuPG version 1.x.
2608
2609 @item --pinentry-mode @code{mode}
2610 @opindex pinentry-mode
2611 Set the pinentry mode to @code{mode}.  Allowed values for @code{mode}
2612 are:
2613 @table @asis
2614   @item default
2615   Use the default of the agent, which is @code{ask}.
2616   @item ask
2617   Force the use of the Pinentry.
2618   @item cancel
2619   Emulate use of Pinentry's cancel button.
2620   @item error
2621   Return a Pinentry error (``No Pinentry'').
2622   @item loopback
2623   Redirect Pinentry queries to the caller.  Note that in contrast to
2624   Pinentry the user is not prompted again if he enters a bad password.
2625 @end table
2626
2627 @item --command-fd @code{n}
2628 @opindex command-fd
2629 This is a replacement for the deprecated shared-memory IPC mode.
2630 If this option is enabled, user input on questions is not expected
2631 from the TTY but from the given file descriptor. It should be used
2632 together with @option{--status-fd}. See the file doc/DETAILS in the source
2633 distribution for details on how to use it.
2634
2635 @item --command-file @code{file}
2636 @opindex command-file
2637 Same as @option{--command-fd}, except the commands are read out of file
2638 @code{file}
2639
2640 @item --allow-non-selfsigned-uid
2641 @itemx --no-allow-non-selfsigned-uid
2642 @opindex allow-non-selfsigned-uid
2643 Allow the import and use of keys with user IDs which are not
2644 self-signed. This is not recommended, as a non self-signed user ID is
2645 trivial to forge. @option{--no-allow-non-selfsigned-uid} disables.
2646
2647 @item --allow-freeform-uid
2648 @opindex allow-freeform-uid
2649 Disable all checks on the form of the user ID while generating a new
2650 one. This option should only be used in very special environments as
2651 it does not ensure the de-facto standard format of user IDs.
2652
2653 @item --ignore-time-conflict
2654 @opindex ignore-time-conflict
2655 GnuPG normally checks that the timestamps associated with keys and
2656 signatures have plausible values. However, sometimes a signature
2657 seems to be older than the key due to clock problems. This option
2658 makes these checks just a warning. See also @option{--ignore-valid-from} for
2659 timestamp issues on subkeys.
2660
2661 @item --ignore-valid-from
2662 @opindex ignore-valid-from
2663 GnuPG normally does not select and use subkeys created in the future.
2664 This option allows the use of such keys and thus exhibits the
2665 pre-1.0.7 behaviour. You should not use this option unless there
2666 is some clock problem. See also @option{--ignore-time-conflict} for timestamp
2667 issues with signatures.
2668
2669 @item --ignore-crc-error
2670 @opindex ignore-crc-error
2671 The ASCII armor used by OpenPGP is protected by a CRC checksum against
2672 transmission errors. Occasionally the CRC gets mangled somewhere on
2673 the transmission channel but the actual content (which is protected by
2674 the OpenPGP protocol anyway) is still okay. This option allows GnuPG
2675 to ignore CRC errors.
2676
2677 @item --ignore-mdc-error
2678 @opindex ignore-mdc-error
2679 This option changes a MDC integrity protection failure into a warning.
2680 This can be useful if a message is partially corrupt, but it is
2681 necessary to get as much data as possible out of the corrupt message.
2682 However, be aware that a MDC protection failure may also mean that the
2683 message was tampered with intentionally by an attacker.
2684
2685 @item --allow-weak-digest-algos
2686 @opindex allow-weak-digest-algos
2687 Signatures made with the broken MD5 algorithm are normally rejected
2688 with an ``invalid digest algorithm'' message.  This option allows the
2689 verification of signatures made with such weak algorithms.
2690
2691 @item --no-default-keyring
2692 @opindex no-default-keyring
2693 Do not add the default keyrings to the list of keyrings. Note that
2694 GnuPG will not operate without any keyrings, so if you use this option
2695 and do not provide alternate keyrings via @option{--keyring} or
2696 @option{--secret-keyring}, then GnuPG will still use the default public or
2697 secret keyrings.
2698
2699 @item --skip-verify
2700 @opindex skip-verify
2701 Skip the signature verification step. This may be
2702 used to make the decryption faster if the signature
2703 verification is not needed.
2704
2705 @item --with-key-data
2706 @opindex with-key-data
2707 Print key listings delimited by colons (like @option{--with-colons}) and
2708 print the public key data.
2709
2710 @item --fast-list-mode
2711 @opindex fast-list-mode
2712 Changes the output of the list commands to work faster; this is achieved
2713 by leaving some parts empty. Some applications don't need the user ID
2714 and the trust information given in the listings. By using this options
2715 they can get a faster listing. The exact behaviour of this option may
2716 change in future versions.  If you are missing some information, don't
2717 use this option.
2718
2719 @item --no-literal
2720 @opindex no-literal
2721 This is not for normal use. Use the source to see for what it might be useful.
2722
2723 @item --set-filesize
2724 @opindex set-filesize
2725 This is not for normal use. Use the source to see for what it might be useful.
2726
2727 @item --show-session-key
2728 @opindex show-session-key
2729 Display the session key used for one message. See
2730 @option{--override-session-key} for the counterpart of this option.
2731
2732 We think that Key Escrow is a Bad Thing; however the user should have
2733 the freedom to decide whether to go to prison or to reveal the content
2734 of one specific message without compromising all messages ever
2735 encrypted for one secret key.
2736
2737 You can also use this option if you receive an encrypted message which
2738 is abusive or offensive, to prove to the administrators of the
2739 messaging system that the ciphertext transmitted corresponds to an
2740 inappropriate plaintext so they can take action against the offending
2741 user.
2742
2743 @item --override-session-key @code{string}
2744 @opindex override-session-key
2745 Don't use the public key but the session key @code{string}. The format
2746 of this string is the same as the one printed by
2747 @option{--show-session-key}. This option is normally not used but comes
2748 handy in case someone forces you to reveal the content of an encrypted
2749 message; using this option you can do this without handing out the
2750 secret key.
2751
2752 @item --ask-sig-expire
2753 @itemx --no-ask-sig-expire
2754 @opindex ask-sig-expire
2755 When making a data signature, prompt for an expiration time. If this
2756 option is not specified, the expiration time set via
2757 @option{--default-sig-expire} is used. @option{--no-ask-sig-expire}
2758 disables this option.
2759
2760 @item --default-sig-expire
2761 @opindex default-sig-expire
2762 The default expiration time to use for signature expiration. Valid
2763 values are "0" for no expiration, a number followed by the letter d
2764 (for days), w (for weeks), m (for months), or y (for years) (for
2765 example "2m" for two months, or "5y" for five years), or an absolute
2766 date in the form YYYY-MM-DD. Defaults to "0".
2767
2768 @item --ask-cert-expire
2769 @itemx --no-ask-cert-expire
2770 @opindex ask-cert-expire
2771 When making a key signature, prompt for an expiration time. If this
2772 option is not specified, the expiration time set via
2773 @option{--default-cert-expire} is used. @option{--no-ask-cert-expire}
2774 disables this option.
2775
2776 @item --default-cert-expire
2777 @opindex default-cert-expire
2778 The default expiration time to use for key signature expiration.
2779 Valid values are "0" for no expiration, a number followed by the
2780 letter d (for days), w (for weeks), m (for months), or y (for years)
2781 (for example "2m" for two months, or "5y" for five years), or an
2782 absolute date in the form YYYY-MM-DD. Defaults to "0".
2783
2784 @item --allow-secret-key-import
2785 @opindex allow-secret-key-import
2786 This is an obsolete option and is not used anywhere.
2787
2788 @item --allow-multiple-messages
2789 @item --no-allow-multiple-messages
2790 @opindex allow-multiple-messages
2791 Allow processing of multiple OpenPGP messages contained in a single file
2792 or stream.  Some programs that call GPG are not prepared to deal with
2793 multiple messages being processed together, so this option defaults to
2794 no.  Note that versions of GPG prior to 1.4.7 always allowed multiple
2795 messages.
2796
2797 Warning: Do not use this option unless you need it as a temporary
2798 workaround!
2799
2800
2801 @item --enable-special-filenames
2802 @opindex enable-special-filenames
2803 This options enables a mode in which filenames of the form
2804 @file{-&n}, where n is a non-negative decimal number,
2805 refer to the file descriptor n and not to a file with that name.
2806
2807 @item --no-expensive-trust-checks
2808 @opindex no-expensive-trust-checks
2809 Experimental use only.
2810
2811 @item --preserve-permissions
2812 @opindex preserve-permissions
2813 Don't change the permissions of a secret keyring back to user
2814 read/write only. Use this option only if you really know what you are doing.
2815
2816 @item --default-preference-list @code{string}
2817 @opindex default-preference-list
2818 Set the list of default preferences to @code{string}. This preference
2819 list is used for new keys and becomes the default for "setpref" in the
2820 edit menu.
2821
2822 @item --default-keyserver-url @code{name}
2823 @opindex default-keyserver-url
2824 Set the default keyserver URL to @code{name}. This keyserver will be
2825 used as the keyserver URL when writing a new self-signature on a key,
2826 which includes key generation and changing preferences.
2827
2828 @item --list-config
2829 @opindex list-config
2830 Display various internal configuration parameters of GnuPG. This option
2831 is intended for external programs that call GnuPG to perform tasks, and
2832 is thus not generally useful. See the file @file{doc/DETAILS} in the
2833 source distribution for the details of which configuration items may be
2834 listed. @option{--list-config} is only usable with
2835 @option{--with-colons} set.
2836
2837 @item --list-gcrypt-config
2838 @opindex list-gcrypt-config
2839 Display various internal configuration parameters of Libgcrypt.
2840
2841 @item --gpgconf-list
2842 @opindex gpgconf-list
2843 This command is similar to @option{--list-config} but in general only
2844 internally used by the @command{gpgconf} tool.
2845
2846 @item --gpgconf-test
2847 @opindex gpgconf-test
2848 This is more or less dummy action.  However it parses the configuration
2849 file and returns with failure if the configuration file would prevent
2850 @command{gpg} from startup.  Thus it may be used to run a syntax check
2851 on the configuration file.
2852
2853 @end table
2854
2855 @c *******************************
2856 @c ******* Deprecated ************
2857 @c *******************************
2858 @node Deprecated Options
2859 @subsection Deprecated options
2860
2861 @table @gnupgtabopt
2862
2863 @item --show-photos
2864 @itemx --no-show-photos
2865 @opindex show-photos
2866 Causes @option{--list-keys}, @option{--list-sigs},
2867 @option{--list-public-keys}, @option{--list-secret-keys}, and verifying
2868 a signature to also display the photo ID attached to the key, if
2869 any. See also @option{--photo-viewer}. These options are deprecated. Use
2870 @option{--list-options [no-]show-photos} and/or @option{--verify-options
2871 [no-]show-photos} instead.
2872
2873 @item --show-keyring
2874 @opindex show-keyring
2875 Display the keyring name at the head of key listings to show which
2876 keyring a given key resides on. This option is deprecated: use
2877 @option{--list-options [no-]show-keyring} instead.
2878
2879 @item --always-trust
2880 @opindex always-trust
2881 Identical to @option{--trust-model always}. This option is deprecated.
2882
2883 @item --show-notation
2884 @itemx --no-show-notation
2885 @opindex show-notation
2886 Show signature notations in the @option{--list-sigs} or @option{--check-sigs} listings
2887 as well as when verifying a signature with a notation in it. These
2888 options are deprecated. Use @option{--list-options [no-]show-notation}
2889 and/or @option{--verify-options [no-]show-notation} instead.
2890
2891 @item --show-policy-url
2892 @itemx --no-show-policy-url
2893 @opindex show-policy-url
2894 Show policy URLs in the @option{--list-sigs} or @option{--check-sigs}
2895 listings as well as when verifying a signature with a policy URL in
2896 it. These options are deprecated. Use @option{--list-options
2897 [no-]show-policy-url} and/or @option{--verify-options
2898 [no-]show-policy-url} instead.
2899
2900
2901 @end table
2902
2903
2904 @c *******************************************
2905 @c ***************            ****************
2906 @c ***************   FILES    ****************
2907 @c ***************            ****************
2908 @c *******************************************
2909 @mansect files
2910 @node GPG Configuration
2911 @section Configuration files
2912
2913 There are a few configuration files to control certain aspects of
2914 @command{@gpgname}'s operation. Unless noted, they are expected in the
2915 current home directory (@pxref{option --homedir}).
2916
2917 @table @file
2918
2919   @item gpg.conf
2920   @cindex gpg.conf
2921   This is the standard configuration file read by @command{@gpgname} on
2922   startup.  It may contain any valid long option; the leading two dashes
2923   may not be entered and the option may not be abbreviated.  This default
2924   name may be changed on the command line (@pxref{gpg-option --options}).
2925   You should backup this file.
2926
2927 @end table
2928
2929 @c man:.RE
2930 Note that on larger installations, it is useful to put predefined files
2931 into the directory @file{@value{SYSCONFSKELDIR}} so that
2932 newly created users start up with a working configuration.
2933 For existing users a small
2934 helper script is provided to create these files (@pxref{addgnupghome}).
2935
2936 For internal purposes @command{@gpgname} creates and maintains a few other
2937 files; They all live in in the current home directory (@pxref{option
2938 --homedir}).  Only the @command{@gpgname} program may modify these files.
2939
2940
2941 @table @file
2942   @item ~/.gnupg/pubring.gpg
2943   The public keyring.  You should backup this file.
2944
2945   @item ~/.gnupg/pubring.gpg.lock
2946   The lock file for the public keyring.
2947
2948   @item ~/.gnupg/pubring.kbx
2949   The public keyring using a different format.  This file is sharred
2950   with @command{gpgsm}.  You should backup this file.
2951
2952   @item ~/.gnupg/pubring.kbx.lock
2953   The lock file for @file{pubring.kbx}.
2954
2955   @item ~/.gnupg/secring.gpg
2956   A secret keyring as used by GnuPG versions before 2.1.  It is not
2957   used by GnuPG 2.1 and later.
2958
2959   @item ~/.gnupg/.gpg-v21-migrated
2960   File indicating that a migration to GnuPG 2.1 has been done.
2961
2962   @item ~/.gnupg/trustdb.gpg
2963   The trust database.  There is no need to backup this file; it is better
2964   to backup the ownertrust values (@pxref{option --export-ownertrust}).
2965
2966   @item ~/.gnupg/trustdb.gpg.lock
2967   The lock file for the trust database.
2968
2969   @item ~/.gnupg/random_seed
2970   A file used to preserve the state of the internal random pool.
2971
2972   @item ~/.gnupg/secring.gpg.lock
2973   The lock file for the secret keyring.
2974
2975   @item ~/.gnupg/openpgp-revocs.d/
2976   This is the directory where gpg stores pre-generated revocation
2977   certificates.  The file name corresponds to the OpenPGP fingerprint of
2978   the respective key.  It is suggested to backup those certificates and
2979   if the primary private key is not stored on the disk to move them to
2980   an external storage device.  Anyone who can access theses files is
2981   able to revoke the corresponding key.  You may want to print them out.
2982   You should backup all files in this directory and take care to keep
2983   this backup closed away.
2984
2985   @item @value{DATADIR}/options.skel
2986   The skeleton options file.
2987
2988   @item @value{LIBDIR}/
2989   Default location for extensions.
2990
2991 @end table
2992
2993 @c man:.RE
2994 Operation is further controlled by a few environment variables:
2995
2996 @table @asis
2997
2998   @item HOME
2999   Used to locate the default home directory.
3000
3001   @item GNUPGHOME
3002   If set directory used instead of "~/.gnupg".
3003
3004   @item GPG_AGENT_INFO
3005   This variable was used by GnuPG versions before 2.1
3006
3007   @item PINENTRY_USER_DATA
3008   This value is passed via gpg-agent to pinentry.  It is useful to convey
3009   extra information to a custom pinentry.
3010
3011   @item COLUMNS
3012   @itemx LINES
3013   Used to size some displays to the full size of the screen.
3014
3015
3016   @item LANGUAGE
3017   Apart from its use by GNU, it is used in the W32 version to override the
3018   language selection done through the Registry.  If used and set to a
3019   valid and available language name (@var{langid}), the file with the
3020   translation is loaded from
3021
3022   @code{@var{gpgdir}/gnupg.nls/@var{langid}.mo}.  Here @var{gpgdir} is the
3023   directory out of which the gpg binary has been loaded.  If it can't be
3024   loaded the Registry is tried and as last resort the native Windows
3025   locale system is used.
3026
3027 @end table
3028
3029
3030 @c *******************************************
3031 @c ***************            ****************
3032 @c ***************  EXAMPLES  ****************
3033 @c ***************            ****************
3034 @c *******************************************
3035 @mansect examples
3036 @node GPG Examples
3037 @section Examples
3038
3039 @table @asis
3040
3041 @item gpg -se -r @code{Bob} @code{file}
3042 sign and encrypt for user Bob
3043
3044 @item gpg --clearsign @code{file}
3045 make a clear text signature
3046
3047 @item gpg -sb @code{file}
3048 make a detached signature
3049
3050 @item gpg -u 0x12345678 -sb @code{file}
3051 make a detached signature with the key 0x12345678
3052
3053 @item gpg --list-keys @code{user_ID}
3054 show keys
3055
3056 @item gpg --fingerprint @code{user_ID}
3057 show fingerprint
3058
3059 @item gpg --verify @code{pgpfile}
3060 @itemx gpg --verify @code{sigfile}
3061 Verify the signature of the file but do not output the data. The
3062 second form is used for detached signatures, where @code{sigfile}
3063 is the detached signature (either ASCII armored or binary) and
3064 are the signed data; if this is not given, the name of
3065 the file holding the signed data is constructed by cutting off the
3066 extension (".asc" or ".sig") of @code{sigfile} or by asking the
3067 user for the filename.
3068 @end table
3069
3070
3071 @c *******************************************
3072 @c ***************            ****************
3073 @c ***************  USER ID   ****************
3074 @c ***************            ****************
3075 @c *******************************************
3076 @mansect how to specify a user id
3077 @ifset isman
3078 @include specify-user-id.texi
3079 @end ifset
3080
3081 @mansect return value
3082 @chapheading RETURN VALUE
3083
3084 The program returns 0 if everything was fine, 1 if at least
3085 a signature was bad, and other error codes for fatal errors.
3086
3087 @mansect warnings
3088 @chapheading WARNINGS
3089
3090 Use a *good* password for your user account and a *good* passphrase
3091 to protect your secret key. This passphrase is the weakest part of the
3092 whole system. Programs to do dictionary attacks on your secret keyring
3093 are very easy to write and so you should protect your "~/.gnupg/"
3094 directory very well.
3095
3096 Keep in mind that, if this program is used over a network (telnet), it
3097 is *very* easy to spy out your passphrase!
3098
3099 If you are going to verify detached signatures, make sure that the
3100 program knows about it; either give both filenames on the command line
3101 or use @samp{-} to specify STDIN.
3102
3103 @mansect interoperability
3104 @chapheading INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS
3105
3106 GnuPG tries to be a very flexible implementation of the OpenPGP
3107 standard. In particular, GnuPG implements many of the optional parts
3108 of the standard, such as the SHA-512 hash, and the ZLIB and BZIP2
3109 compression algorithms. It is important to be aware that not all
3110 OpenPGP programs implement these optional algorithms and that by
3111 forcing their use via the @option{--cipher-algo},
3112 @option{--digest-algo}, @option{--cert-digest-algo}, or
3113 @option{--compress-algo} options in GnuPG, it is possible to create a
3114 perfectly valid OpenPGP message, but one that cannot be read by the
3115 intended recipient.
3116
3117 There are dozens of variations of OpenPGP programs available, and each
3118 supports a slightly different subset of these optional algorithms.
3119 For example, until recently, no (unhacked) version of PGP supported
3120 the BLOWFISH cipher algorithm. A message using BLOWFISH simply could
3121 not be read by a PGP user. By default, GnuPG uses the standard
3122 OpenPGP preferences system that will always do the right thing and
3123 create messages that are usable by all recipients, regardless of which
3124 OpenPGP program they use. Only override this safe default if you
3125 really know what you are doing.
3126
3127 If you absolutely must override the safe default, or if the preferences
3128 on a given key are invalid for some reason, you are far better off using
3129 the @option{--pgp6}, @option{--pgp7}, or @option{--pgp8} options. These
3130 options are safe as they do not force any particular algorithms in
3131 violation of OpenPGP, but rather reduce the available algorithms to a
3132 "PGP-safe" list.
3133
3134 @mansect bugs
3135 @chapheading BUGS
3136
3137 On older systems this program should be installed as setuid(root). This
3138 is necessary to lock memory pages. Locking memory pages prevents the
3139 operating system from writing memory pages (which may contain
3140 passphrases or other sensitive material) to disk. If you get no
3141 warning message about insecure memory your operating system supports
3142 locking without being root. The program drops root privileges as soon
3143 as locked memory is allocated.
3144
3145 Note also that some systems (especially laptops) have the ability to
3146 ``suspend to disk'' (also known as ``safe sleep'' or ``hibernate'').
3147 This writes all memory to disk before going into a low power or even
3148 powered off mode.  Unless measures are taken in the operating system
3149 to protect the saved memory, passphrases or other sensitive material
3150 may be recoverable from it later.
3151
3152 Before you report a bug you should first search the mailing list
3153 archives for similar problems and second check whether such a bug has
3154 already been reported to our bug tracker at http://bugs.gnupg.org .
3155
3156 @c *******************************************
3157 @c ***************              **************
3158 @c ***************  UNATTENDED  **************
3159 @c ***************              **************
3160 @c *******************************************
3161 @manpause
3162 @node Unattended Usage of GPG
3163 @section Unattended Usage
3164
3165 @command{gpg} is often used as a backend engine by other software.  To help
3166 with this a machine interface has been defined to have an unambiguous
3167 way to do this.  The options @option{--status-fd} and @option{--batch}
3168 are almost always required for this.
3169
3170 @menu
3171 * Unattended GPG key generation::  Unattended key generation
3172 @end menu
3173
3174
3175 @node Unattended GPG key generation
3176 @subsection Unattended key generation
3177
3178 The command @option{--gen-key} may be used along with the option
3179 @option{--batch} for unattended key generation.  The parameters are
3180 either read from stdin or given as a file on the command line.
3181 The format of the parameter file is as follows:
3182
3183 @itemize @bullet
3184   @item Text only, line length is limited to about 1000 characters.
3185   @item UTF-8 encoding must be used to specify non-ASCII characters.
3186   @item Empty lines are ignored.
3187   @item Leading and trailing while space is ignored.
3188   @item A hash sign as the first non white space character indicates
3189   a comment line.
3190   @item Control statements are indicated by a leading percent sign, the
3191   arguments are separated by white space from the keyword.
3192   @item Parameters are specified by a keyword, followed by a colon.  Arguments
3193   are separated by white space.
3194   @item
3195   The first parameter must be @samp{Key-Type}; control statements may be
3196   placed anywhere.
3197   @item
3198   The order of the parameters does not matter except for @samp{Key-Type}
3199   which must be the first parameter.  The parameters are only used for
3200   the generated keyblock (primary and subkeys); parameters from previous
3201   sets are not used.  Some syntactically checks may be performed.
3202   @item
3203   Key generation takes place when either the end of the parameter file
3204   is reached, the next @samp{Key-Type} parameter is encountered or at the
3205   control statement @samp{%commit} is encountered.
3206 @end itemize
3207
3208 @noindent
3209 Control statements:
3210
3211 @table @asis
3212
3213 @item %echo @var{text}
3214 Print @var{text} as diagnostic.
3215
3216 @item %dry-run
3217 Suppress actual key generation (useful for syntax checking).
3218
3219 @item %commit
3220 Perform the key generation.  Note that an implicit commit is done at
3221 the next @asis{Key-Type} parameter.
3222
3223 @item %pubring @var{filename}
3224 @itemx %secring @var{filename}
3225 Do not write the key to the default or commandline given keyring but
3226 to @var{filename}.  This must be given before the first commit to take
3227 place, duplicate specification of the same filename is ignored, the
3228 last filename before a commit is used.  The filename is used until a
3229 new filename is used (at commit points) and all keys are written to
3230 that file. If a new filename is given, this file is created (and
3231 overwrites an existing one).  For GnuPG versions prior to 2.1, both
3232 control statements must be given. For GnuPG 2.1 and later
3233 @samp{%secring} is a no-op.
3234
3235 @item %ask-passphrase
3236 @itemx %no-ask-passphrase
3237 This option is a no-op for GnuPG 2.1 and later.
3238
3239 @item %no-protection
3240 Using this option allows the creation of keys without any passphrase
3241 protection.  This option is mainly intended for regression tests.
3242
3243 @item %transient-key
3244 If given the keys are created using a faster and a somewhat less
3245 secure random number generator.  This option may be used for keys
3246 which are only used for a short time and do not require full
3247 cryptographic strength.  It takes only effect if used together with
3248 the control statement @samp{%no-protection}.
3249
3250 @end table
3251
3252 @noindent
3253 General Parameters:
3254
3255 @table @asis
3256
3257 @item Key-Type: @var{algo}
3258 Starts a new parameter block by giving the type of the primary
3259 key. The algorithm must be capable of signing.  This is a required
3260 parameter.  @var{algo} may either be an OpenPGP algorithm number or a
3261 string with the algorithm name.  The special value @samp{default} may
3262 be used for @var{algo} to create the default key type; in this case a
3263 @samp{Key-Usage} shall not be given and @samp{default} also be used
3264 for @samp{Subkey-Type}.
3265
3266 @item Key-Length: @var{nbits}
3267 The requested length of the generated key in bits.  The default is
3268 returned by running the command @samp{gpg2 --gpgconf-list}.
3269
3270 @item Key-Grip: @var{hexstring}
3271 This is optional and used to generate a CSR or certificate for an
3272 already existing key.  Key-Length will be ignored when given.
3273
3274 @item Key-Usage: @var{usage-list}
3275 Space or comma delimited list of key usages.  Allowed values are
3276 @samp{encrypt}, @samp{sign}, and @samp{auth}.  This is used to
3277 generate the key flags.  Please make sure that the algorithm is
3278 capable of this usage.  Note that OpenPGP requires that all primary
3279 keys are capable of certification, so no matter what usage is given
3280 here, the @samp{cert} flag will be on.  If no @samp{Key-Usage} is
3281 specified and the @samp{Key-Type} is not @samp{default}, all allowed
3282 usages for that particular algorithm are used; if it is not given but
3283 @samp{default} is used the usage will be @samp{sign}.
3284
3285 @item Subkey-Type: @var{algo}
3286 This generates a secondary key (subkey).  Currently only one subkey
3287 can be handled.  See also @samp{Key-Type} above.
3288
3289 @item Subkey-Length: @var{nbits}
3290 Length of the secondary key (subkey) in bits.  The default is returned
3291 by running the command @samp{gpg2 --gpgconf-list}".
3292
3293 @item Subkey-Usage: @var{usage-list}
3294 Key usage lists for a subkey; similar to @samp{Key-Usage}.
3295
3296 @item Passphrase: @var{string}
3297 If you want to specify a passphrase for the secret key, enter it here.
3298 Default is to use the Pinentry dialog to ask for a passphrase.
3299
3300 @item Name-Real: @var{name}
3301 @itemx Name-Comment: @var{comment}
3302 @itemx Name-Email: @var{email}
3303 The three parts of a user name.  Remember to use UTF-8 encoding here.
3304 If you don't give any of them, no user ID is created.
3305
3306 @item Expire-Date: @var{iso-date}|(@var{number}[d|w|m|y])
3307 Set the expiration date for the key (and the subkey).  It may either
3308 be entered in ISO date format (e.g. "20000815T145012") or as number of
3309 days, weeks, month or years after the creation date.  The special
3310 notation "seconds=N" is also allowed to specify a number of seconds
3311 since creation.  Without a letter days are assumed.  Note that there
3312 is no check done on the overflow of the type used by OpenPGP for
3313 timestamps.  Thus you better make sure that the given value make
3314 sense.  Although OpenPGP works with time intervals, GnuPG uses an
3315 absolute value internally and thus the last year we can represent is
3316 2105.
3317
3318 @item  Creation-Date: @var{iso-date}
3319 Set the creation date of the key as stored in the key information and
3320 which is also part of the fingerprint calculation.  Either a date like
3321 "1986-04-26" or a full timestamp like "19860426T042640" may be used.
3322 The time is considered to be UTC.  The special notation "seconds=N"
3323 may be used to directly specify a the number of seconds since Epoch
3324 (Unix time).  If it is not given the current time is used.
3325
3326 @item Preferences: @var{string}
3327 Set the cipher, hash, and compression preference values for this key.
3328 This expects the same type of string as the sub-command @samp{setpref}
3329 in the @option{--edit-key} menu.
3330
3331 @item  Revoker: @var{algo}:@var{fpr} [sensitive]
3332 Add a designated revoker to the generated key.  Algo is the public key
3333 algorithm of the designated revoker (i.e. RSA=1, DSA=17, etc.)
3334 @var{fpr} is the fingerprint of the designated revoker.  The optional
3335 @samp{sensitive} flag marks the designated revoker as sensitive
3336 information.  Only v4 keys may be designated revokers.
3337
3338 @item Keyserver: @var{string}
3339 This is an optional parameter that specifies the preferred keyserver
3340 URL for the key.
3341
3342 @item Handle: @var{string}
3343 This is an optional parameter only used with the status lines
3344 KEY_CREATED and KEY_NOT_CREATED.  @var{string} may be up to 100
3345 characters and should not contain spaces.  It is useful for batch key
3346 generation to associate a key parameter block with a status line.
3347
3348 @end table
3349
3350 @noindent
3351 Here is an example on how to create a key:
3352 @smallexample
3353 $ cat >foo <<EOF
3354      %echo Generating a basic OpenPGP key
3355      Key-Type: DSA
3356      Key-Length: 1024
3357      Subkey-Type: ELG-E
3358      Subkey-Length: 1024
3359      Name-Real: Joe Tester
3360      Name-Comment: with stupid passphrase
3361      Name-Email: joe@@foo.bar
3362      Expire-Date: 0
3363      Passphrase: abc
3364      %pubring foo.pub
3365      %secring foo.sec
3366      # Do a commit here, so that we can later print "done" :-)
3367      %commit
3368      %echo done
3369 EOF
3370 $ gpg2 --batch --gen-key foo
3371  [...]
3372 $ gpg2 --no-default-keyring --secret-keyring ./foo.sec \
3373        --keyring ./foo.pub --list-secret-keys
3374 /home/wk/work/gnupg-stable/scratch/foo.sec
3375 ------------------------------------------
3376 sec  1024D/915A878D 2000-03-09 Joe Tester (with stupid passphrase) <joe@@foo.bar>
3377 ssb  1024g/8F70E2C0 2000-03-09
3378 @end smallexample
3379
3380
3381 @noindent
3382 If you want to create a key with the default algorithms you would use
3383 these parameters:
3384 @smallexample
3385      %echo Generating a default key
3386      Key-Type: default
3387      Subkey-Type: default
3388      Name-Real: Joe Tester
3389      Name-Comment: with stupid passphrase
3390      Name-Email: joe@@foo.bar
3391      Expire-Date: 0
3392      Passphrase: abc
3393      %pubring foo.pub
3394      %secring foo.sec
3395      # Do a commit here, so that we can later print "done" :-)
3396      %commit
3397      %echo done
3398 @end smallexample
3399
3400
3401
3402
3403 @mansect see also
3404 @ifset isman
3405 @command{gpgv}(1),
3406 @command{gpgsm}(1),
3407 @command{gpg-agent}(1)
3408 @end ifset
3409 @include see-also-note.texi