1 @c Copyright (C) 2002 Free Software Foundation, Inc.
2 @c This is part of the GnuPG manual.
3 @c For copying conditions, see the file gnupg.texi.
7 @node Invoking GPG-AGENT
8 @chapter Invoking GPG-AGENT
9 @cindex GPG-AGENT command options
10 @cindex command options
11 @cindex options, GPG-AGENT command
16 \- Secret key management for GnuPG
47 @command{gpg-agent} is a daemon to manage secret (private) keys
48 independently from any protocol. It is used as a backend for
49 @command{gpg} and @command{gpgsm} as well as for a couple of other
52 The agent is automatically started on demand by @command{gpg},
53 @command{gpgsm}, @command{gpgconf}, or @command{gpg-connect-agent}.
54 Thus there is no reason to start it manually. In case you want to use
55 the included Secure Shell Agent you may start the agent using:
57 @c From dkg on gnupg-devel on 2016-04-21:
59 @c Here's an attempt at writing a short description of the goals of an
60 @c isolated cryptographic agent:
62 @c A cryptographic agent should control access to secret key material.
63 @c The agent permits use of the secret key material by a supplicant
64 @c without providing a copy of the secret key material to the supplicant.
66 @c An isolated cryptographic agent separates the request for use of
67 @c secret key material from permission for use of secret key material.
68 @c That is, the system or process requesting use of the key (the
69 @c "supplicant") can be denied use of the key by the owner/operator of
70 @c the agent (the "owner"), which the supplicant has no control over.
72 @c One way of enforcing this split is a per-key or per-session
73 @c passphrase, known only by the owner, which must be supplied to the
74 @c agent to permit the use of the secret key material. Another way is
75 @c with an out-of-band permission mechanism (e.g. a button or GUI
76 @c interface that the owner has access to, but the supplicant does not).
78 @c The rationale for this separation is that it allows access to the
79 @c secret key to be tightly controlled and audited, and it doesn't permit
80 @c the supplicant to either copy the key or to override the owner's
84 gpg-connect-agent /bye
88 If you want to manually terminate the currently-running agent, you can
92 gpgconf --kill gpg-agent
97 You should always add the following lines to your @code{.bashrc} or
98 whatever initialization file is used for all shell invocations:
106 It is important that this environment variable always reflects the
107 output of the @code{tty} command. For W32 systems this option is not
110 Please make sure that a proper pinentry program has been installed
111 under the default filename (which is system dependent) or use the
112 option @option{pinentry-program} to specify the full name of that program.
113 It is often useful to install a symbolic link from the actual used
114 pinentry (e.g. @file{@value{BINDIR}/pinentry-gtk}) to the expected
115 one (e.g. @file{@value{BINDIR}/pinentry}).
119 @xref{Option Index}, for an index to @command{GPG-AGENT}'s commands and options.
123 * Agent Commands:: List of all commands.
124 * Agent Options:: List of all options.
125 * Agent Configuration:: Configuration files.
126 * Agent Signals:: Use of some signals.
127 * Agent Examples:: Some usage examples.
128 * Agent Protocol:: The protocol the agent uses.
135 Commands are not distinguished from options except for the fact that
136 only one command is allowed.
141 Print the program version and licensing information. Note that you cannot
142 abbreviate this command.
147 Print a usage message summarizing the most useful command-line options.
148 Note that you cannot abbreviate this command.
151 @opindex dump-options
152 Print a list of all available options and commands. Note that you cannot
153 abbreviate this command.
157 Run in server mode and wait for commands on the @code{stdin}. The
158 default mode is to create a socket and listen for commands there.
160 @item --daemon [@var{command line}]
162 Start the gpg-agent as a daemon; that is, detach it from the console
163 and run it in the background.
165 As an alternative you may create a new process as a child of
166 gpg-agent: @code{gpg-agent --daemon /bin/sh}. This way you get a new
167 shell with the environment setup properly; after you exit from this
168 shell, gpg-agent terminates within a few seconds.
172 Run in the foreground, sending logs by default to stderr, and
173 listening on provided file descriptors, which must already be bound to
174 listening sockets. This option is deprecated and not supported on
177 If in @file{common.conf} the option @option{no-autostart} is set, any
178 start attempts will be ignored.
180 In --supervised mode, different file descriptors can be provided for
181 use as different socket types (e.g. ssh, extra) as long as they are
182 identified in the environment variable @code{LISTEN_FDNAMES} (see
183 sd_listen_fds(3) on some Linux distributions for more information on
189 @section Option Summary
191 Options may either be used on the command line or, after stripping off
192 the two leading dashes, in the configuration file.
196 @anchor{option --options}
197 @item --options @var{file}
199 Reads configuration from @var{file} instead of from the default
200 per-user configuration file. The default configuration file is named
201 @file{gpg-agent.conf} and expected in the @file{.gnupg} directory
202 directly below the home directory of the user. This option is ignored
203 if used in an options file.
205 @anchor{option --homedir}
206 @include opt-homedir.texi
212 Outputs additional information while running.
213 You can increase the verbosity by giving several
214 verbose commands to @command{gpg-agent}, such as @samp{-vv}.
219 Try to be as quiet as possible.
223 Don't invoke a pinentry or do any other thing requiring human interaction.
225 @item --faked-system-time @var{epoch}
226 @opindex faked-system-time
227 This option is only useful for testing; it sets the system time back or
228 forth to @var{epoch} which is the number of seconds elapsed since the year
231 @item --debug-level @var{level}
233 Select the debug level for investigating problems. @var{level} may be
234 a numeric value or a keyword:
238 No debugging at all. A value of less than 1 may be used instead of
241 Some basic debug messages. A value between 1 and 2 may be used
242 instead of the keyword.
244 More verbose debug messages. A value between 3 and 5 may be used
245 instead of the keyword.
247 Even more detailed messages. A value between 6 and 8 may be used
248 instead of the keyword.
250 All of the debug messages you can get. A value greater than 8 may be
251 used instead of the keyword. The creation of hash tracing files is
252 only enabled if the keyword is used.
255 How these messages are mapped to the actual debugging flags is not
256 specified and may change with newer releases of this program. They are
257 however carefully selected to best aid in debugging.
259 @item --debug @var{flags}
261 Set debug flags. All flags are or-ed and @var{flags} may be given
262 in C syntax (e.g. 0x0042) or as a comma separated list of flag names.
263 To get a list of all supported flags the single word "help" can be
264 used. This option is only useful for debugging and the behavior may
265 change at any time without notice.
269 Same as @code{--debug=0xffffffff}
271 @item --debug-wait @var{n}
273 When running in server mode, wait @var{n} seconds before entering the
274 actual processing loop and print the pid. This gives time to attach a
277 @item --debug-quick-random
278 @opindex debug-quick-random
279 This option inhibits the use of the very secure random quality level
280 (Libgcrypt’s @code{GCRY_VERY_STRONG_RANDOM}) and degrades all request
281 down to standard random quality. It is only used for testing and
282 should not be used for any production quality keys. This option is
283 only effective when given on the command line.
285 On GNU/Linux, another way to quickly generate insecure keys is to use
286 @command{rngd} to fill the kernel's entropy pool with lower quality
287 random data. @command{rngd} is typically provided by the
288 @command{rng-tools} package. It can be run as follows: @samp{sudo
289 rngd -f -r /dev/urandom}.
291 @item --debug-pinentry
292 @opindex debug-pinentry
293 This option enables extra debug information pertaining to the
294 Pinentry. As of now it is only useful when used along with
299 Don't detach the process from the console. This is mainly useful for
303 @opindex steal-socket
304 In @option{--daemon} mode, gpg-agent detects an already running
305 gpg-agent and does not allow to start a new instance. This option can
306 be used to override this check: the new gpg-agent process will try to
307 take over the communication sockets from the already running process
308 and start anyway. This option should in general not be used.
318 Format the info output in daemon mode for use with the standard Bourne
319 shell or the C-shell respectively. The default is to guess it based on
320 the environment variable @code{SHELL} which is correct in almost all
328 Tell the pinentry to grab the keyboard and mouse. This option should
329 be used on X-Servers to avoid X-sniffing attacks. Any use of the
330 option @option{--grab} overrides an used option @option{--no-grab}.
331 The default is @option{--no-grab}.
333 @anchor{option --log-file}
334 @item --log-file @var{file}
336 @efindex HKCU\Software\GNU\GnuPG:DefaultLogFile
337 Append all logging output to @var{file}. This is very helpful in
338 seeing what the agent actually does. Use @file{socket://} to log to
339 socket. If neither a log file nor a log file descriptor has been set
340 on a Windows platform, the Registry entry
341 @code{HKCU\Software\GNU\GnuPG:DefaultLogFile}, if set, is used to
342 specify the logging output.
345 @anchor{option --no-allow-mark-trusted}
346 @item --no-allow-mark-trusted
347 @opindex no-allow-mark-trusted
348 Do not allow clients to mark keys as trusted, i.e. put them into the
349 @file{trustlist.txt} file. This makes it harder for users to inadvertently
353 @anchor{option --no-user-trustlist}
354 @item --no-user-trustlist
355 @opindex no-user-trustlist
356 Entirely ignore the user trust list and consider only the global
357 trustlist (@file{@value{SYSCONFDIR}/trustlist.txt}). This
358 implies the @ref{option --no-allow-mark-trusted}.
360 @item --sys-trustlist-name @var{file}
361 @opindex sys-trustlist-name
362 Changes the default name for the global trustlist from "trustlist.txt"
363 to @var{file}. If @var{file} does not contain any slashes and does
364 not start with "~/" it is searched in the system configuration
365 directory (@file{@value{SYSCONFDIR}}).
367 @anchor{option --allow-preset-passphrase}
368 @item --allow-preset-passphrase
369 @opindex allow-preset-passphrase
370 This option allows the use of @command{gpg-preset-passphrase} to seed the
371 internal cache of @command{gpg-agent} with passphrases.
373 @anchor{option --no-allow-loopback-pinentry}
374 @item --no-allow-loopback-pinentry
375 @item --allow-loopback-pinentry
376 @opindex no-allow-loopback-pinentry
377 @opindex allow-loopback-pinentry
378 Disallow or allow clients to use the loopback pinentry features; see
379 the option @option{pinentry-mode} for details. Allow is the default.
381 The @option{--force} option of the Assuan command @command{DELETE_KEY}
382 is also controlled by this option: The option is ignored if a loopback
383 pinentry is disallowed.
385 @item --no-allow-external-cache
386 @opindex no-allow-external-cache
387 Tell Pinentry not to enable features which use an external cache for
390 Some desktop environments prefer to unlock all
391 credentials with one master password and may have installed a Pinentry
392 which employs an additional external cache to implement such a policy.
393 By using this option the Pinentry is advised not to make use of such a
394 cache and instead always ask the user for the requested passphrase.
396 @item --allow-emacs-pinentry
397 @opindex allow-emacs-pinentry
398 Tell Pinentry to allow features to divert the passphrase entry to a
399 running Emacs instance. How this is exactly handled depends on the
400 version of the used Pinentry.
402 @item --ignore-cache-for-signing
403 @opindex ignore-cache-for-signing
404 This option will let @command{gpg-agent} bypass the passphrase cache for all
405 signing operation. Note that there is also a per-session option to
406 control this behavior but this command line option takes precedence.
408 @item --default-cache-ttl @var{n}
409 @opindex default-cache-ttl
410 Set the time a cache entry is valid to @var{n} seconds. The default
411 is 600 seconds. Each time a cache entry is accessed, the entry's
412 timer is reset. To set an entry's maximum lifetime, use
413 @command{max-cache-ttl}. Note that a cached passphrase may not be
414 evicted immediately from memory if no client requests a cache
415 operation. This is due to an internal housekeeping function which is
416 only run every few seconds.
418 @item --default-cache-ttl-ssh @var{n}
419 @opindex default-cache-ttl
420 Set the time a cache entry used for SSH keys is valid to @var{n}
421 seconds. The default is 1800 seconds. Each time a cache entry is
422 accessed, the entry's timer is reset. To set an entry's maximum
423 lifetime, use @command{max-cache-ttl-ssh}.
425 @item --max-cache-ttl @var{n}
426 @opindex max-cache-ttl
427 Set the maximum time a cache entry is valid to @var{n} seconds. After
428 this time a cache entry will be expired even if it has been accessed
429 recently or has been set using @command{gpg-preset-passphrase}. The
430 default is 2 hours (7200 seconds).
432 @item --max-cache-ttl-ssh @var{n}
433 @opindex max-cache-ttl-ssh
434 Set the maximum time a cache entry used for SSH keys is valid to
435 @var{n} seconds. After this time a cache entry will be expired even
436 if it has been accessed recently or has been set using
437 @command{gpg-preset-passphrase}. The default is 2 hours (7200
440 @item --enforce-passphrase-constraints
441 @opindex enforce-passphrase-constraints
442 Enforce the passphrase constraints by not allowing the user to bypass
443 them using the ``Take it anyway'' button.
445 @item --min-passphrase-len @var{n}
446 @opindex min-passphrase-len
447 Set the minimal length of a passphrase. When entering a new passphrase
448 shorter than this value a warning will be displayed. Defaults to 8.
450 @item --min-passphrase-nonalpha @var{n}
451 @opindex min-passphrase-nonalpha
452 Set the minimal number of digits or special characters required in a
453 passphrase. When entering a new passphrase with less than this number
454 of digits or special characters a warning will be displayed. Defaults
457 @item --check-passphrase-pattern @var{file}
458 @itemx --check-sym-passphrase-pattern @var{file}
459 @opindex check-passphrase-pattern
460 @opindex check-sym-passphrase-pattern
461 Check the passphrase against the pattern given in @var{file}. When
462 entering a new passphrase matching one of these pattern a warning will
463 be displayed. If @var{file} does not contain any slashes and does not
464 start with "~/" it is searched in the system configuration directory
465 (@file{@value{SYSCONFDIR}}). The default is not to use any
466 pattern file. The second version of this option is only used when
467 creating a new symmetric key to allow the use of different patterns
468 for such passphrases.
470 Security note: It is known that checking a passphrase against a list of
471 pattern or even against a complete dictionary is not very effective to
472 enforce good passphrases. Users will soon figure up ways to bypass such
473 a policy. A better policy is to educate users on good security
474 behavior and optionally to run a passphrase cracker regularly on all
475 users passphrases to catch the very simple ones.
477 @item --max-passphrase-days @var{n}
478 @opindex max-passphrase-days
479 Ask the user to change the passphrase if @var{n} days have passed since
480 the last change. With @option{--enforce-passphrase-constraints} set the
481 user may not bypass this check.
483 @item --enable-passphrase-history
484 @opindex enable-passphrase-history
485 This option does nothing yet.
487 @item --pinentry-invisible-char @var{char}
488 @opindex pinentry-invisible-char
489 This option asks the Pinentry to use @var{char} for displaying hidden
490 characters. @var{char} must be one character UTF-8 string. A
491 Pinentry may or may not honor this request.
493 @item --pinentry-timeout @var{n}
494 @opindex pinentry-timeout
495 This option asks the Pinentry to timeout after @var{n} seconds with no
496 user input. The default value of 0 does not ask the pinentry to
497 timeout, however a Pinentry may use its own default timeout value in
498 this case. A Pinentry may or may not honor this request.
500 @item --pinentry-formatted-passphrase
501 @opindex pinentry-formatted-passphrase
502 This option asks the Pinentry to enable passphrase formatting when asking the
503 user for a new passphrase and masking of the passphrase is turned off.
505 If passphrase formatting is enabled, then all non-breaking space characters
506 are stripped from the entered passphrase. Passphrase formatting is mostly
507 useful in combination with passphrases generated with the GENPIN
508 feature of some Pinentries. Note that such a generated
509 passphrase, if not modified by the user, skips all passphrase
510 constraints checking because such constraints would actually weaken
511 the generated passphrase.
513 @item --pinentry-program @var{filename}
514 @opindex pinentry-program
515 Use program @var{filename} as the PIN entry. The default is
516 installation dependent. With the default configuration the name of
517 the default pinentry is @file{pinentry}; if that file does not exist
518 but a @file{pinentry-basic} exist the latter is used.
520 On a Windows platform the default is to use the first existing program
522 @file{bin\pinentry.exe},
523 @file{..\Gpg4win\bin\pinentry.exe},
524 @file{..\Gpg4win\pinentry.exe},
525 @file{..\GNU\GnuPG\pinentry.exe},
526 @file{..\GNU\bin\pinentry.exe},
527 @file{bin\pinentry-basic.exe}
528 where the file names are relative to the GnuPG installation directory.
531 @item --pinentry-touch-file @var{filename}
532 @opindex pinentry-touch-file
533 By default the filename of the socket gpg-agent is listening for
534 requests is passed to Pinentry, so that it can touch that file before
535 exiting (it does this only in curses mode). This option changes the
536 file passed to Pinentry to @var{filename}. The special name
537 @code{/dev/null} may be used to completely disable this feature. Note
538 that Pinentry will not create that file, it will only change the
539 modification and access time.
542 @item --scdaemon-program @var{filename}
543 @opindex scdaemon-program
544 Use program @var{filename} as the Smartcard daemon. The default is
545 installation dependent and can be shown with the @command{gpgconf}
548 @item --disable-scdaemon
549 @opindex disable-scdaemon
550 Do not make use of the scdaemon tool. This option has the effect of
551 disabling the ability to do smartcard operations. Note, that enabling
552 this option at runtime does not kill an already forked scdaemon.
554 @item --disable-check-own-socket
555 @opindex disable-check-own-socket
556 @command{gpg-agent} employs a periodic self-test to detect a stolen
557 socket. This usually means a second instance of @command{gpg-agent}
558 has taken over the socket and @command{gpg-agent} will then terminate
559 itself. This option may be used to disable this self-test for
562 @item --use-standard-socket
563 @itemx --no-use-standard-socket
564 @itemx --use-standard-socket-p
565 @opindex use-standard-socket
566 @opindex no-use-standard-socket
567 @opindex use-standard-socket-p
568 Since GnuPG 2.1 the standard socket is always used. These options
569 have no more effect. The command @code{gpg-agent
570 --use-standard-socket-p} will thus always return success.
572 @item --display @var{string}
573 @itemx --ttyname @var{string}
574 @itemx --ttytype @var{string}
575 @itemx --lc-ctype @var{string}
576 @itemx --lc-messages @var{string}
577 @itemx --xauthority @var{string}
584 These options are used with the server mode to pass localization
588 @itemx --keep-display
590 @opindex keep-display
591 Ignore requests to change the current @code{tty} or X window system's
592 @code{DISPLAY} variable respectively. This is useful to lock the
593 pinentry to pop up at the @code{tty} or display you started the agent.
595 @item --listen-backlog @var{n}
596 @opindex listen-backlog
597 Set the size of the queue for pending connections. The default is 64.
599 @anchor{option --extra-socket}
600 @item --extra-socket @var{name}
601 @opindex extra-socket
602 The extra socket is created by default, you may use this option to
603 change the name of the socket. To disable the creation of the socket
604 use ``none'' or ``/dev/null'' for @var{name}.
606 Also listen on native gpg-agent connections on the given socket. The
607 intended use for this extra socket is to setup a Unix domain socket
608 forwarding from a remote machine to this socket on the local machine.
609 A @command{gpg} running on the remote machine may then connect to the
610 local gpg-agent and use its private keys. This enables decrypting or
611 signing data on a remote machine without exposing the private keys to the
614 @item --enable-extended-key-format
615 @itemx --disable-extended-key-format
616 @opindex enable-extended-key-format
617 @opindex disable-extended-key-format
618 These options are obsolete and have no effect. The extended key format
619 is used for years now and has been supported since 2.1.12. Existing
620 keys in the old format are migrated to the new format as soon as they
624 @anchor{option --enable-ssh-support}
625 @item --enable-ssh-support
626 @itemx --enable-putty-support
627 @opindex enable-ssh-support
628 @opindex enable-putty-support
630 The OpenSSH Agent protocol is always enabled, but @command{gpg-agent}
631 will only set the @code{SSH_AUTH_SOCK} variable if this flag is given.
633 In this mode of operation, the agent does not only implement the
634 gpg-agent protocol, but also the agent protocol used by OpenSSH
635 (through a separate socket). Consequently, it should be possible to use
636 the gpg-agent as a drop-in replacement for the well known ssh-agent.
638 SSH Keys, which are to be used through the agent, need to be added to
639 the gpg-agent initially through the ssh-add utility. When a key is
640 added, ssh-add will ask for the password of the provided key file and
641 send the unprotected key material to the agent; this causes the
642 gpg-agent to ask for a passphrase, which is to be used for encrypting
643 the newly received key and storing it in a gpg-agent specific
646 Once a key has been added to the gpg-agent this way, the gpg-agent
647 will be ready to use the key.
649 Note: in case the gpg-agent receives a signature request, the user might
650 need to be prompted for a passphrase, which is necessary for decrypting
651 the stored key. Since the ssh-agent protocol does not contain a
652 mechanism for telling the agent on which display/terminal it is running,
653 gpg-agent's ssh-support will use the TTY or X display where gpg-agent
654 has been started. To switch this display to the current one, the
655 following command may be used:
658 gpg-connect-agent updatestartuptty /bye
661 Although all GnuPG components try to start the gpg-agent as needed, this
662 is not possible for the ssh support because ssh does not know about it.
663 Thus if no GnuPG tool which accesses the agent has been run, there is no
664 guarantee that ssh is able to use gpg-agent for authentication. To fix
665 this you may start gpg-agent if needed using this simple command:
668 gpg-connect-agent /bye
671 Adding the @option{--verbose} shows the progress of starting the agent.
673 The @option{--enable-putty-support} is only available under Windows
674 and allows the use of gpg-agent with the ssh implementation
675 @command{putty}. This is similar to the regular ssh-agent support but
676 makes use of Windows message queue as required by @command{putty}.
679 The order in which keys are presented to ssh are:
682 @item Negative Use-for-ssh values
683 If a key file has the attribute "Use-for-ssh" and its value is
684 negative, these keys are presented first to ssh. The negative
685 values are capped at -999 with -999 beeing lower ranked than -1.
686 These values can be used to prefer on-disk keys over keys taken
690 Active cards (inserted into a card reader or plugged in tokens)
691 are always tried; they are ordered by their serial numbers.
693 @item Keys listed in the sshcontrol file
694 Non-disabled keys from the sshcontrol file are presented in the
695 order they appear in this file. Note that the sshcontrol file
698 @item Positive Use-for-ssh values
699 If a key file has the attribute "Use-for-ssh" and its value is
700 "yes", "true", or any positive number the key is presented in
701 the order of their values. "yes" and "true" have a value of 1;
702 other values are capped at 99999.
706 Editing the "Use-for-ssh" values can be done with an editor or using
707 @command{gpg-connect-agent} and "KEYATTR" (Remember to append a colon
708 to the key; i.e. use "Use-for-ssh:").
711 @anchor{option --ssh-fingerprint-digest}
712 @item --ssh-fingerprint-digest
713 @opindex ssh-fingerprint-digest
715 Select the digest algorithm used to compute ssh fingerprints that are
716 communicated to the user, e.g. in pinentry dialogs. OpenSSH has
717 transitioned from using MD5 to the more secure SHA256.
720 @item --auto-expand-secmem @var{n}
721 @opindex auto-expand-secmem
722 Allow Libgcrypt to expand its secure memory area as required. The
723 optional value @var{n} is a non-negative integer with a suggested size
724 in bytes of each additionally allocated secure memory area. The value
725 is rounded up to the next 32 KiB; usual C style prefixes are allowed.
726 For an heavy loaded gpg-agent with many concurrent connection this
727 option avoids sign or decrypt errors due to out of secure memory error
730 @item --s2k-calibration @var{milliseconds}
731 @opindex s2k-calibration
732 Change the default calibration time to @var{milliseconds}. The given
733 value is capped at 60 seconds; a value of 0 resets to the compiled-in
734 default. This option is re-read on a SIGHUP (or @code{gpgconf
735 --reload gpg-agent}) and the S2K count is then re-calibrated.
737 @item --s2k-count @var{n}
739 Specify the iteration count used to protect the passphrase. This
740 option can be used to override the auto-calibration done by default.
741 The auto-calibration computes a count which requires by default 100ms
742 to mangle a given passphrase. See also @option{--s2k-calibration}.
744 To view the actually used iteration count and the milliseconds
745 required for an S2K operation use:
748 gpg-connect-agent 'GETINFO s2k_count' /bye
749 gpg-connect-agent 'GETINFO s2k_time' /bye
752 To view the auto-calibrated count use:
755 gpg-connect-agent 'GETINFO s2k_count_cal' /bye
763 @node Agent Configuration
764 @section Configuration
766 There are a few configuration files needed for the operation of the
767 agent. By default they may all be found in the current home directory
768 (@pxref{option --homedir}).
773 @efindex gpg-agent.conf
774 This is the standard configuration file read by @command{gpg-agent} on
775 startup. It may contain any valid long option; the leading
776 two dashes may not be entered and the option may not be abbreviated.
777 This file is also read after a @code{SIGHUP} however only a few
778 options will actually have an effect. This default name may be
779 changed on the command line (@pxref{option --options}).
780 You should backup this file.
783 @efindex trustlist.txt
784 This is the list of trusted keys. You should backup this file.
786 Comment lines, indicated by a leading hash mark, as well as empty
787 lines are ignored. To mark a key as trusted you need to enter its
788 fingerprint followed by a space and a capital letter @code{S}. Colons
789 may optionally be used to separate the bytes of a fingerprint; this
790 enables cutting and pasting the fingerprint from a key listing output. If
791 the line is prefixed with a @code{!} the key is explicitly marked as
794 Here is an example where two keys are marked as ultimately trusted
795 and one as not trusted:
799 # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
800 A6935DD34EF3087973C706FC311AA2CCF733765B S
802 # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
803 DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
805 # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
806 !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
810 Before entering a key into this file, you need to ensure its
811 authenticity. How to do this depends on your organisation; your
812 administrator might have already entered those keys which are deemed
813 trustworthy enough into this file. Places where to look for the
814 fingerprint of a root certificate are letters received from the CA or
815 the website of the CA (after making 100% sure that this is indeed the
816 website of that CA). You may want to consider disallowing interactive
817 updates of this file by using the @ref{option --no-allow-mark-trusted}.
818 It might even be advisable to change the permissions to read-only so
819 that this file can't be changed inadvertently.
821 As a special feature a line @code{include-default} will include a global
822 list of trusted certificates (e.g. @file{@value{SYSCONFDIR}/trustlist.txt}).
823 This global list is also used if the local list is not available;
824 the @ref{option --no-user-trustlist} enforces the use of only
827 It is possible to add further flags after the @code{S} for use by the
834 Relax checking of some root certificate requirements. As of now this
835 flag allows the use of root certificates with a missing basicConstraints
836 attribute (despite that it is a MUST for CA certificates) and disables
837 CRL checking for the root certificate.
840 If validation of a certificate finally issued by a CA with this flag set
841 fails, try again using the chain validation model.
844 The CA is allowed to issue certificates for qualified signatures.
845 This flag has an effect only if used in the global list. This is now
846 the preferred way to mark such CA; the old way of having a separate
847 file @file{qualified.txt} is still supported.
850 The CA is part of an approved PKI for the German classification level
851 VS-NfD. It is only valid in the global trustlist. As of now this is
852 used only for documentation purpose.
859 This file is used when support for the secure shell agent protocol has
860 been enabled (@pxref{option --enable-ssh-support}). Only keys present in
861 this file are used in the SSH protocol. You should backup this file.
863 This file is deprecated in favor of the "Use-for-ssh" attribute in the
866 The @command{ssh-add} tool may be used to add new entries to this file;
867 you may also add them manually. Comment lines, indicated by a leading
868 hash mark, as well as empty lines are ignored. An entry starts with
869 optional whitespace, followed by the keygrip of the key given as 40 hex
870 digits, optionally followed by the caching TTL in seconds and another
871 optional field for arbitrary flags. A non-zero TTL overrides the global
872 default as set by @option{--default-cache-ttl-ssh}.
874 The only flag support is @code{confirm}. If this flag is found for a
875 key, each use of the key will pop up a pinentry to confirm the use of
876 that key. The flag is automatically set if a new key was loaded into
877 @code{gpg-agent} using the option @option{-c} of the @code{ssh-add}
880 The keygrip may be prefixed with a @code{!} to disable an entry.
882 The following example lists exactly one key. Note that keys available
883 through a OpenPGP smartcard in the active smartcard reader are
884 implicitly added to this list; i.e. there is no need to list them.
888 # Key added on: 2011-07-20 20:38:46
889 # Fingerprint: 5e:8d:c4:ad:e7:af:6e:27:8a:d6:13:e4:79:ad:0b:81
890 34B62F25E277CF13D3C6BCEBFD3F85D08F0A864B 0 confirm
894 @item private-keys-v1.d/
895 @efindex private-keys-v1.d
897 This is the directory where gpg-agent stores the private keys. Each
898 key is stored in a file with the name made up of the keygrip and the
899 suffix @file{key}. You should backup all files in this directory
900 and take great care to keep this backup closed away.
905 Note that on larger installations, it is useful to put predefined
906 files into the directory @file{@value{SYSCONFSKELDIR}} so that newly created
907 users start up with a working configuration. For existing users the
908 a small helper script is provided to create these files (@pxref{addgnupghome}).
916 @section Use of some signals
917 A running @command{gpg-agent} may be controlled by signals, i.e. using
918 the @command{kill} command to send a signal to the process.
920 Here is a list of supported signals:
926 This signal flushes all cached passphrases and if the program has been
927 started with a configuration file, the configuration file is read
928 again. Only certain options are honored: @code{quiet},
929 @code{verbose}, @code{debug}, @code{debug-all}, @code{debug-level},
930 @code{debug-pinentry},
932 @code{pinentry-program},
933 @code{pinentry-invisible-char},
934 @code{default-cache-ttl},
935 @code{max-cache-ttl}, @code{ignore-cache-for-signing},
937 @code{no-allow-external-cache}, @code{allow-emacs-pinentry},
938 @code{no-allow-mark-trusted}, @code{disable-scdaemon}, and
939 @code{disable-check-own-socket}. @code{scdaemon-program} is also
940 supported but due to the current implementation, which calls the
941 scdaemon only once, it is not of much use unless you manually kill the
947 Shuts down the process but waits until all current requests are
948 fulfilled. If the process has received 3 of these signals and requests
949 are still pending, a shutdown is forced.
953 Shuts down the process immediately.
957 Dump internal information to the log file.
961 This signal is used for internal purposes.
972 It is important to set the environment variable @code{GPG_TTY} in
973 your login shell, for example in the @file{~/.bashrc} init script:
977 export GPG_TTY=$(tty)
981 If you enabled the Ssh Agent Support, you also need to tell ssh about
982 it by adding this to your init script:
987 if [ "$@{gnupg_SSH_AUTH_SOCK_by:-0@}" -ne $$ ]; then
988 export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
999 @section Agent's Assuan Protocol
1001 Note: this section does only document the protocol, which is used by
1002 GnuPG components; it does not deal with the ssh-agent protocol. To
1003 see the full specification of each command, use
1006 gpg-connect-agent 'help COMMAND' /bye
1010 or just 'help' to list all available commands.
1013 The @command{gpg-agent} daemon is started on demand by the GnuPG
1016 To identify a key we use a thing called keygrip which is the SHA-1 hash
1017 of an canonical encoded S-Expression of the public key as used in
1018 Libgcrypt. For the purpose of this interface the keygrip is given as a
1019 hex string. The advantage of using this and not the hash of a
1020 certificate is that it will be possible to use the same keypair for
1021 different protocols, thereby saving space on the token used to keep the
1024 The @command{gpg-agent} may send status messages during a command or when
1025 returning from a command to inform a client about the progress or result of an
1026 operation. For example, the @var{INQUIRE_MAXLEN} status message may be sent
1027 during a server inquire to inform the client of the maximum usable length of
1028 the inquired data (which should not be exceeded).
1031 * Agent PKDECRYPT:: Decrypting a session key
1032 * Agent PKSIGN:: Signing a Hash
1033 * Agent GENKEY:: Generating a Key
1034 * Agent IMPORT:: Importing a Secret Key
1035 * Agent EXPORT:: Exporting a Secret Key
1036 * Agent ISTRUSTED:: Importing a Root Certificate
1037 * Agent GET_PASSPHRASE:: Ask for a passphrase
1038 * Agent CLEAR_PASSPHRASE:: Expire a cached passphrase
1039 * Agent PRESET_PASSPHRASE:: Set a passphrase for a keygrip
1040 * Agent GET_CONFIRMATION:: Ask for confirmation
1041 * Agent HAVEKEY:: Check whether a key is available
1042 * Agent LEARN:: Register a smartcard
1043 * Agent PASSWD:: Change a Passphrase
1044 * Agent UPDATESTARTUPTTY:: Change the Standard Display
1045 * Agent GETEVENTCOUNTER:: Get the Event Counters
1046 * Agent GETINFO:: Return information about the process
1047 * Agent OPTION:: Set options for the session
1050 @node Agent PKDECRYPT
1051 @subsection Decrypting a session key
1053 The client asks the server to decrypt a session key. The encrypted
1054 session key should have all information needed to select the
1055 appropriate secret key or to delegate it to a smartcard.
1061 Tell the server about the key to be used for decryption. If this is
1062 not used, @command{gpg-agent} may try to figure out the key by trying to
1063 decrypt the message with each key available.
1069 The agent checks whether this command is allowed and then does an
1070 INQUIRY to get the ciphertext the client should then send the cipher
1074 S: INQUIRE CIPHERTEXT
1080 Please note that the server may send status info lines while reading the
1081 data lines from the client. The data send is a SPKI like S-Exp with
1087 (<param_name1> <mpi>)
1089 (<param_namen> <mpi>)))
1092 Where algo is a string with the name of the algorithm; see the libgcrypt
1093 documentation for a list of valid algorithms. The number and names of
1094 the parameters depend on the algorithm. The agent does return an error
1095 if there is an inconsistency.
1097 If the decryption was successful the decrypted data is returned by
1100 Here is an example session:
1104 S: INQUIRE CIPHERTEXT
1105 C: D (enc-val elg (a 349324324)
1106 C: D (b 3F444677CA)))
1108 S: # session key follows
1110 S: D (value 1234567890ABCDEF0)
1111 S: OK decryption successful
1115 The “PADDING” status line is only send if gpg-agent can tell what kind
1116 of padding is used. As of now only the value 0 is used to indicate
1117 that the padding has been removed.
1121 @subsection Signing a Hash
1123 The client asks the agent to sign a given hash value. A default key
1124 will be chosen if no key has been set. To set a key a client first
1131 This can be used multiple times to create multiple signature, the list
1132 of keys is reset with the next PKSIGN command or a RESET. The server
1133 tests whether the key is a valid key to sign something and responds with
1137 SETHASH --hash=<name>|<algo> <hexstring>
1140 The client can use this command to tell the server about the data <hexstring>
1141 (which usually is a hash) to be signed. <algo> is the decimal encoded hash
1142 algorithm number as used by Libgcrypt. Either <algo> or --hash=<name>
1143 must be given. Valid names for <name> are:
1147 The SHA-1 hash algorithm
1149 The SHA-256 hash algorithm
1151 The RIPE-MD160 hash algorithm
1153 The old and broken MD5 hash algorithm
1155 A combined hash algorithm as used by the TLS protocol.
1159 The actual signing is done using
1165 Options are not yet defined, but may later be used to choose among
1166 different algorithms. The agent does then some checks, asks for the
1167 passphrase and as a result the server returns the signature as an SPKI
1168 like S-expression in "D" lines:
1173 (<param_name1> <mpi>)
1175 (<param_namen> <mpi>)))
1179 The operation is affected by the option
1182 OPTION use-cache-for-signing=0|1
1185 The default of @code{1} uses the cache. Setting this option to @code{0}
1186 will lead @command{gpg-agent} to ignore the passphrase cache. Note, that there is
1187 also a global command line option for @command{gpg-agent} to globally disable the
1191 Here is an example session:
1199 S: # I did ask the user whether he really wants to sign
1200 S: # I did ask the user for the passphrase
1202 C: D ABCDEF012345678901234
1204 S: # signature follows
1205 S: D (sig-val rsa (s 45435453654612121212))
1211 @subsection Generating a Key
1213 This is used to create a new keypair and store the secret key inside the
1214 active PSE --- which is in most cases a Soft-PSE. A not-yet-defined
1215 option allows choosing the storage location. To get the secret key out
1216 of the PSE, a special export tool has to be used.
1219 GENKEY [--no-protection] [--preset] [<cache_nonce>]
1222 Invokes the key generation process and the server will then inquire
1223 on the generation parameters, like:
1227 C: D (genkey (rsa (nbits 1024)))
1231 The format of the key parameters which depends on the algorithm is of
1237 (parameter_name_1 ....)
1239 (parameter_name_n ....)))
1242 If everything succeeds, the server returns the *public key* in a SPKI
1243 like S-Expression like this:
1252 Here is an example session:
1257 C: D (genkey (rsa (nbits 1024)))
1260 S: D (rsa (n 326487324683264) (e 10001)))
1265 The @option{--no-protection} option may be used to prevent prompting for a
1266 passphrase to protect the secret key while leaving the secret key unprotected.
1267 The @option{--preset} option may be used to add the passphrase to the cache
1268 using the default cache parameters.
1270 The @option{--inq-passwd} option may be used to create the key with a
1271 supplied passphrase. When used the agent does an inquiry with the
1272 keyword @code{NEWPASSWD} to retrieve that passphrase. This option
1273 takes precedence over @option{--no-protection}; however if the client
1274 sends a empty (zero-length) passphrase, this is identical to
1275 @option{--no-protection}.
1278 @subsection Importing a Secret Key
1280 This operation is not yet supported by GpgAgent. Specialized tools
1281 are to be used for this.
1283 There is no actual need because we can expect that secret keys
1284 created by a 3rd party are stored on a smartcard. If we have
1285 generated the key ourselves, we do not need to import it.
1288 @subsection Export a Secret Key
1292 Should be done by an extra tool.
1294 @node Agent ISTRUSTED
1295 @subsection Importing a Root Certificate
1297 Actually we do not import a Root Cert but provide a way to validate
1298 any piece of data by storing its Hash along with a description and
1299 an identifier in the PSE. Here is the interface description:
1302 ISTRUSTED <fingerprint>
1305 Check whether the OpenPGP primary key or the X.509 certificate with the
1306 given fingerprint is an ultimately trusted key or a trusted Root CA
1307 certificate. The fingerprint should be given as a hexstring (without
1308 any blanks or colons or whatever in between) and may be left padded with
1309 00 in case of an MD5 fingerprint. GPGAgent will answer with:
1315 The key is in the table of trusted keys.
1318 ERR 304 (Not Trusted)
1321 The key is not in this table.
1323 Gpg needs the entire list of trusted keys to maintain the web of
1324 trust; the following command is therefore quite helpful:
1330 GpgAgent returns a list of trusted keys line by line:
1333 S: D 000000001234454556565656677878AF2F1ECCFF P
1334 S: D 340387563485634856435645634856438576457A P
1335 S: D FEDC6532453745367FD83474357495743757435D S
1339 The first item on a line is the hexified fingerprint where MD5
1340 fingerprints are @code{00} padded to the left and the second item is a
1341 flag to indicate the type of key (so that gpg is able to only take care
1342 of PGP keys). P = OpenPGP, S = S/MIME. A client should ignore the rest
1343 of the line, so that we can extend the format in the future.
1345 Finally a client should be able to mark a key as trusted:
1348 MARKTRUSTED @var{fingerprint} "P"|"S"
1351 The server will then pop up a window to ask the user whether she
1352 really trusts this key. For this it will probably ask for a text to
1353 be displayed like this:
1356 S: INQUIRE TRUSTDESC
1357 C: D Do you trust the key with the fingerprint @@FPR@@
1358 C: D bla fasel blurb.
1363 Known sequences with the pattern @@foo@@ are replaced according to this
1368 Format the fingerprint according to gpg rules for a v3 keys.
1370 Format the fingerprint according to gpg rules for a v4 keys.
1372 Choose an appropriate format to format the fingerprint.
1374 Replaced by a single @code{@@}.
1377 @node Agent GET_PASSPHRASE
1378 @subsection Ask for a passphrase
1380 This function is usually used to ask for a passphrase to be used for
1381 symmetric encryption, but may also be used by programs which need
1382 special handling of passphrases. This command uses a syntax which helps
1383 clients to use the agent with minimum effort.
1386 GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]] \
1387 [--qualitybar] @var{cache_id} \
1388 [@var{error_message} @var{prompt} @var{description}]
1391 @var{cache_id} is expected to be a string used to identify a cached
1392 passphrase. Use a @code{X} to bypass the cache. With no other
1393 arguments the agent returns a cached passphrase or an error. By
1394 convention either the hexified fingerprint of the key shall be used for
1395 @var{cache_id} or an arbitrary string prefixed with the name of the
1396 calling application and a colon: Like @code{gpg:somestring}.
1398 @var{error_message} is either a single @code{X} for no error message or
1399 a string to be shown as an error message like (e.g. "invalid
1400 passphrase"). Blanks must be percent escaped or replaced by @code{+}'.
1402 @var{prompt} is either a single @code{X} for a default prompt or the
1403 text to be shown as the prompt. Blanks must be percent escaped or
1404 replaced by @code{+}.
1406 @var{description} is a text shown above the entry field. Blanks must be
1407 percent escaped or replaced by @code{+}.
1409 The agent either returns with an error or with a OK followed by the hex
1410 encoded passphrase. Note that the length of the strings is implicitly
1411 limited by the maximum length of a command. If the option
1412 @option{--data} is used, the passphrase is not returned on the OK line
1413 but by regular data lines; this is the preferred method.
1415 If the option @option{--check} is used, the standard passphrase
1416 constraints checks are applied. A check is not done if the passphrase
1417 has been found in the cache.
1419 If the option @option{--no-ask} is used and the passphrase is not in the
1420 cache the user will not be asked to enter a passphrase but the error
1421 code @code{GPG_ERR_NO_DATA} is returned.
1423 If the option @option{--qualitybar} is used and a minimum passphrase
1424 length has been configured, a visual indication of the entered
1425 passphrase quality is shown.
1428 CLEAR_PASSPHRASE @var{cache_id}
1431 may be used to invalidate the cache entry for a passphrase. The
1432 function returns with OK even when there is no cached passphrase.
1436 @node Agent CLEAR_PASSPHRASE
1437 @subsection Remove a cached passphrase
1439 Use this command to remove a cached passphrase.
1442 CLEAR_PASSPHRASE [--mode=normal] <cache_id>
1445 The @option{--mode=normal} option can be used to clear a @var{cache_id} that
1446 was set by gpg-agent.
1449 @node Agent PRESET_PASSPHRASE
1450 @subsection Set a passphrase for a keygrip
1452 This command adds a passphrase to the cache for the specified @var{keygrip}.
1455 PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]
1458 The passphrase is a hexadecimal string when specified. When not specified, the
1459 passphrase will be retrieved from the pinentry module unless the
1460 @option{--inquire} option was specified in which case the passphrase will be
1461 retrieved from the client.
1463 The @var{timeout} parameter keeps the passphrase cached for the specified
1464 number of seconds. A value of @code{-1} means infinite while @code{0} means
1465 the default (currently only a timeout of -1 is allowed, which means to never
1469 @node Agent GET_CONFIRMATION
1470 @subsection Ask for confirmation
1472 This command may be used to ask for a simple confirmation by
1473 presenting a text and 2 buttons: Okay and Cancel.
1476 GET_CONFIRMATION @var{description}
1479 @var{description}is displayed along with a Okay and Cancel
1480 button. Blanks must be percent escaped or replaced by @code{+}. A
1481 @code{X} may be used to display confirmation dialog with a default
1484 The agent either returns with an error or with a OK. Note, that the
1485 length of @var{description} is implicitly limited by the maximum
1486 length of a command.
1491 @subsection Check whether a key is available
1493 This can be used to see whether a secret key is available. It does
1494 not return any information on whether the key is somehow protected.
1497 HAVEKEY @var{keygrips}
1500 The agent answers either with OK or @code{No_Secret_Key} (208). The
1501 caller may want to check for other error codes as well. More than one
1502 keygrip may be given. In this case the command returns success if at
1503 least one of the keygrips corresponds to an available secret key.
1507 @subsection Register a smartcard
1513 This command is used to register a smartcard. With the @option{--send}
1514 option given the certificates are sent back.
1518 @subsection Change a Passphrase
1521 PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] @var{keygrip}
1524 This command is used to interactively change the passphrase of the key
1525 identified by the hex string @var{keygrip}. The @option{--preset}
1526 option may be used to add the new passphrase to the cache using the
1527 default cache parameters.
1530 @node Agent UPDATESTARTUPTTY
1531 @subsection Change the standard display
1537 Set the startup TTY and X-DISPLAY variables to the values of this
1538 session. This command is useful to direct future pinentry invocations
1539 to another screen. It is only required because there is no way in the
1540 ssh-agent protocol to convey this information.
1543 @node Agent GETEVENTCOUNTER
1544 @subsection Get the Event Counters
1550 This function return one status line with the current values of the
1551 event counters. The event counters are useful to avoid polling by
1552 delaying a poll until something has changed. The values are decimal
1553 numbers in the range @code{0} to @code{UINT_MAX} and wrapping around to
1554 0. The actual values should not be relied upon; they shall only be used
1557 The currently defined counters are:
1560 Incremented with any change of any of the other counters.
1562 Incremented for added or removed private keys.
1564 Incremented for each change of the card reader's status.
1568 @subsection Return information about the process
1570 This is a multipurpose function to return a variety of information.
1576 The value of @var{what} specifies the kind of information returned:
1579 Return the version of the program.
1581 Return the process id of the process.
1583 Return the name of the socket used to connect the agent.
1584 @item ssh_socket_name
1585 Return the name of the socket used for SSH connections. If SSH support
1586 has not been enabled the error @code{GPG_ERR_NO_DATA} will be returned.
1590 @subsection Set options for the session
1592 Here is a list of session options which are not yet described with
1593 other commands. The general syntax for an Assuan option is:
1596 OPTION @var{key}=@var{value}
1600 Supported @var{key}s are:
1603 @item agent-awareness
1604 This may be used to tell gpg-agent of which gpg-agent version the
1605 client is aware of. gpg-agent uses this information to enable
1606 features which might break older clients.
1609 Change the session's environment to be used for the
1610 Pinentry. Valid values are:
1614 Delete envvar @var{name}
1616 Set envvar @var{name} to the empty string
1617 @item @var{name}=@var{value}
1618 Set envvar @var{name} to the string @var{value}.
1621 @item use-cache-for-signing
1622 See Assuan command @code{PKSIGN}.
1624 @item allow-pinentry-notify
1625 This does not need any value. It is used to enable the
1626 PINENTRY_LAUNCHED inquiry.
1629 This option is used to change the operation mode of the pinentry. The
1630 following values are defined:
1634 This is the default mode which pops up a pinentry as needed.
1637 Instead of popping up a pinentry, return the error code
1638 @code{GPG_ERR_CANCELED}.
1641 Instead of popping up a pinentry, return the error code
1642 @code{GPG_ERR_NO_PIN_ENTRY}.
1645 Use a loopback pinentry. This fakes a pinentry by using inquiries
1646 back to the caller to ask for a passphrase. This option may only be
1647 set if the agent has been configured for that.
1648 To disable this feature use @ref{option --no-allow-loopback-pinentry}.
1651 @item cache-ttl-opt-preset
1652 This option sets the cache TTL for new entries created by GENKEY and
1653 PASSWD commands when using the @option{--preset} option. It is not
1654 used a default value is used.
1657 Instead of using the standard S2K count (which is computed on the
1658 fly), the given S2K count is used for new keys or when changing the
1659 passphrase of a key. Values below 65536 are considered to be 0. This
1660 option is valid for the entire session or until reset to 0. This
1661 option is useful if the key is later used on boxes which are either
1662 much slower or faster than the actual box.
1664 @item pretend-request-origin
1665 This option switches the connection into a restricted mode which
1666 handles all further commands in the same way as they would be handled
1667 when originating from the extra or browser socket. Note that this
1668 option is not available in the restricted mode. Valid values for this
1674 This is a NOP and leaves the connection in the standard way.
1677 Pretend to come from a remote origin in the same way as connections
1678 from the @option{--extra-socket}.
1681 Pretend to come from a local web browser in the same way as connections
1682 from the @option{--browser-socket}.
1690 @command{@gpgname}(1),
1692 @command{gpgconf}(1),
1693 @command{gpg-connect-agent}(1),
1694 @command{scdaemon}(1)
1696 @include see-also-note.texi