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 controled and audited, and it doesn't permit
80 @c the the supplicant to either copy the key or to override the owner's
84 gpg-connect-agent /bye
88 You should always add the following lines to your @code{.bashrc} or
89 whatever initialization file is used for all shell invocations:
97 It is important that this environment variable always reflects the
98 output of the @code{tty} command. For W32 systems this option is not
101 Please make sure that a proper pinentry program has been installed
102 under the default filename (which is system dependent) or use the
103 option @option{pinentry-program} to specify the full name of that program.
104 It is often useful to install a symbolic link from the actual used
105 pinentry (e.g. @file{@value{BINDIR}/pinentry-gtk}) to the expected
106 one (e.g. @file{@value{BINDIR}/pinentry}).
110 @xref{Option Index},for an index to @command{GPG-AGENT}'s commands and options.
114 * Agent Commands:: List of all commands.
115 * Agent Options:: List of all options.
116 * Agent Configuration:: Configuration files.
117 * Agent Signals:: Use of some signals.
118 * Agent Examples:: Some usage examples.
119 * Agent Protocol:: The protocol the agent uses.
126 Commands are not distinguished from options except for the fact that
127 only one command is allowed.
132 Print the program version and licensing information. Note that you cannot
133 abbreviate this command.
138 Print a usage message summarizing the most useful command-line options.
139 Note that you cannot abbreviate this command.
142 @opindex dump-options
143 Print a list of all available options and commands. Note that you cannot
144 abbreviate this command.
148 Run in server mode and wait for commands on the @code{stdin}. The
149 default mode is to create a socket and listen for commands there.
151 @item --daemon [@var{command line}]
153 Start the gpg-agent as a daemon; that is, detach it from the console
154 and run it in the background.
156 As an alternative you may create a new process as a child of
157 gpg-agent: @code{gpg-agent --daemon /bin/sh}. This way you get a new
158 shell with the environment setup properly; after you exit from this
159 shell, gpg-agent terminates within a few seconds.
164 @section Option Summary
168 @anchor{option --options}
169 @item --options @var{file}
171 Reads configuration from @var{file} instead of from the default
172 per-user configuration file. The default configuration file is named
173 @file{gpg-agent.conf} and expected in the @file{.gnupg} directory directly
174 below the home directory of the user.
176 @anchor{option --homedir}
177 @include opt-homedir.texi
183 Outputs additional information while running.
184 You can increase the verbosity by giving several
185 verbose commands to @command{gpgsm}, such as @samp{-vv}.
190 Try to be as quiet as possible.
194 Don't invoke a pinentry or do any other thing requiring human interaction.
196 @item --faked-system-time @var{epoch}
197 @opindex faked-system-time
198 This option is only useful for testing; it sets the system time back or
199 forth to @var{epoch} which is the number of seconds elapsed since the year
202 @item --debug-level @var{level}
204 Select the debug level for investigating problems. @var{level} may be
205 a numeric value or a keyword:
209 No debugging at all. A value of less than 1 may be used instead of
212 Some basic debug messages. A value between 1 and 2 may be used
213 instead of the keyword.
215 More verbose debug messages. A value between 3 and 5 may be used
216 instead of the keyword.
218 Even more detailed messages. A value between 6 and 8 may be used
219 instead of the keyword.
221 All of the debug messages you can get. A value greater than 8 may be
222 used instead of the keyword. The creation of hash tracing files is
223 only enabled if the keyword is used.
226 How these messages are mapped to the actual debugging flags is not
227 specified and may change with newer releases of this program. They are
228 however carefully selected to best aid in debugging.
230 @item --debug @var{flags}
232 This option is only useful for debugging and the behaviour may change at
233 any time without notice. FLAGS are bit encoded and may be given in
234 usual C-Syntax. The currently defined bits are:
238 X.509 or OpenPGP protocol related data
240 values of big number integers
242 low level crypto operations
248 show memory statistics.
250 write hashed data to files named @code{dbgmd-000*}
252 trace Assuan protocol
254 bypass all certificate validation
259 Same as @code{--debug=0xffffffff}
261 @item --debug-wait @var{n}
263 When running in server mode, wait @var{n} seconds before entering the
264 actual processing loop and print the pid. This gives time to attach a
267 @item --debug-quick-random
268 @opindex debug-quick-random
269 This option inhibits the use of the very secure random quality level
270 (Libgcrypt’s @code{GCRY_VERY_STRONG_RANDOM}) and degrades all request
271 down to standard random quality. It is only used for testing and
272 should not be used for any production quality keys. This option is
273 only effective when given on the command line.
275 On GNU/Linux, another way to quickly generate insecure keys is to use
276 @command{rngd} to fill the kernel's entropy pool with lower quality
277 random data. @command{rngd} is typically provided by the
278 @command{rng-tools} package. It can be run as follows: @samp{sudo
279 rngd -f -r /dev/urandom}.
281 @item --debug-pinentry
282 @opindex debug-pinentry
283 This option enables extra debug information pertaining to the
284 Pinentry. As of now it is only useful when used along with
289 Don't detach the process from the console. This is mainly useful for
298 Format the info output in daemon mode for use with the standard Bourne
299 shell or the C-shell respectively. The default is to guess it based on
300 the environment variable @code{SHELL} which is correct in almost all
306 Tell the pinentry not to grab the keyboard and mouse. This option
307 should in general not be used to avoid X-sniffing attacks.
309 @anchor{option --log-file}
310 @item --log-file @var{file}
312 Append all logging output to @var{file}. This is very helpful in seeing
313 what the agent actually does. If neither a log file nor a log file
314 descriptor has been set on a Windows platform, the Registry entry
315 @code{HKCU\Software\GNU\GnuPG:DefaultLogFile}, if set, is used to specify
319 @anchor{option --no-allow-mark-trusted}
320 @item --no-allow-mark-trusted
321 @opindex no-allow-mark-trusted
322 Do not allow clients to mark keys as trusted, i.e. put them into the
323 @file{trustlist.txt} file. This makes it harder for users to inadvertently
326 @anchor{option --allow-preset-passphrase}
327 @item --allow-preset-passphrase
328 @opindex allow-preset-passphrase
329 This option allows the use of @command{gpg-preset-passphrase} to seed the
330 internal cache of @command{gpg-agent} with passphrases.
332 @anchor{option --no-allow-loopback-pinentry}
333 @item --no-allow-loopback-pinentry
334 @item --allow-loopback-pinentry
335 @opindex no-allow-loopback-pinentry
336 @opindex allow-loopback-pinentry
337 Disallow or allow clients to use the loopback pinentry features; see
338 the option @option{pinentry-mode} for details. Allow is the default.
340 The @option{--force} option of the Assuan command @command{DELETE_KEY}
341 is also controlled by this option: The option is ignored if a loopback
342 pinentry is disallowed.
344 @item --no-allow-external-cache
345 @opindex no-allow-external-cache
346 Tell Pinentry not to enable features which use an external cache for
349 Some desktop environments prefer to unlock all
350 credentials with one master password and may have installed a Pinentry
351 which employs an additional external cache to implement such a policy.
352 By using this option the Pinentry is advised not to make use of such a
353 cache and instead always ask the user for the requested passphrase.
355 @item --allow-emacs-pinentry
356 @opindex allow-emacs-pinentry
357 Tell Pinentry to allow features to divert the passphrase entry to a
358 running Emacs instance. How this is exactly handled depends on the
359 version of the used Pinentry.
361 @item --ignore-cache-for-signing
362 @opindex ignore-cache-for-signing
363 This option will let @command{gpg-agent} bypass the passphrase cache for all
364 signing operation. Note that there is also a per-session option to
365 control this behaviour but this command line option takes precedence.
367 @item --default-cache-ttl @var{n}
368 @opindex default-cache-ttl
369 Set the time a cache entry is valid to @var{n} seconds. The default
370 is 600 seconds. Each time a cache entry is accessed, the entry's
371 timer is reset. To set an entry's maximum lifetime, use
372 @command{max-cache-ttl}.
374 @item --default-cache-ttl-ssh @var{n}
375 @opindex default-cache-ttl
376 Set the time a cache entry used for SSH keys is valid to @var{n}
377 seconds. The default is 1800 seconds. Each time a cache entry is
378 accessed, the entry's timer is reset. To set an entry's maximum
379 lifetime, use @command{max-cache-ttl-ssh}.
381 @item --max-cache-ttl @var{n}
382 @opindex max-cache-ttl
383 Set the maximum time a cache entry is valid to @var{n} seconds. After
384 this time a cache entry will be expired even if it has been accessed
385 recently or has been set using @command{gpg-preset-passphrase}. The
386 default is 2 hours (7200 seconds).
388 @item --max-cache-ttl-ssh @var{n}
389 @opindex max-cache-ttl-ssh
390 Set the maximum time a cache entry used for SSH keys is valid to
391 @var{n} seconds. After this time a cache entry will be expired even
392 if it has been accessed recently or has been set using
393 @command{gpg-preset-passphrase}. The default is 2 hours (7200
396 @item --enforce-passphrase-constraints
397 @opindex enforce-passphrase-constraints
398 Enforce the passphrase constraints by not allowing the user to bypass
399 them using the ``Take it anyway'' button.
401 @item --min-passphrase-len @var{n}
402 @opindex min-passphrase-len
403 Set the minimal length of a passphrase. When entering a new passphrase
404 shorter than this value a warning will be displayed. Defaults to 8.
406 @item --min-passphrase-nonalpha @var{n}
407 @opindex min-passphrase-nonalpha
408 Set the minimal number of digits or special characters required in a
409 passphrase. When entering a new passphrase with less than this number
410 of digits or special characters a warning will be displayed. Defaults
413 @item --check-passphrase-pattern @var{file}
414 @opindex check-passphrase-pattern
415 Check the passphrase against the pattern given in @var{file}. When
416 entering a new passphrase matching one of these pattern a warning will
417 be displayed. @var{file} should be an absolute filename. The default is
418 not to use any pattern file.
420 Security note: It is known that checking a passphrase against a list of
421 pattern or even against a complete dictionary is not very effective to
422 enforce good passphrases. Users will soon figure up ways to bypass such
423 a policy. A better policy is to educate users on good security
424 behavior and optionally to run a passphrase cracker regularly on all
425 users passphrases to catch the very simple ones.
427 @item --max-passphrase-days @var{n}
428 @opindex max-passphrase-days
429 Ask the user to change the passphrase if @var{n} days have passed since
430 the last change. With @option{--enforce-passphrase-constraints} set the
431 user may not bypass this check.
433 @item --enable-passphrase-history
434 @opindex enable-passphrase-history
435 This option does nothing yet.
437 @item --pinentry-invisible-char @var{char}
438 @opindex pinentry-invisible-char
439 This option asks the Pinentry to use @var{char} for displaying hidden
440 characters. @var{char} must be one character UTF-8 string. A
441 Pinentry may or may not honor this request.
443 @item --pinentry-timeout @var{n}
444 @opindex pinentry-timeout
445 This option asks the Pinentry to timeout after @var{n} seconds with no
446 user input. The default value of 0 does not ask the pinentry to
447 timeout, however a Pinentry may use its own default timeout value in
448 this case. A Pinentry may or may not honor this request.
450 @item --pinentry-program @var{filename}
451 @opindex pinentry-program
452 Use program @var{filename} as the PIN entry. The default is
453 installation dependent. With the default configuration the name of
454 the default pinentry is @file{pinentry}; if that file does not exist
455 but a @file{pinentry-basic} exist the latter is used.
457 On a Windows platform the default is to use the first existing program
459 @file{bin\pinentry.exe},
460 @file{..\Gpg4win\bin\pinentry.exe},
461 @file{..\Gpg4win\pinentry.exe},
462 @file{..\GNU\GnuPG\pinentry.exe},
463 @file{..\GNU\bin\pinentry.exe},
464 @file{bin\pinentry-basic.exe}
465 where the file names are relative to the GnuPG installation directory.
468 @item --pinentry-touch-file @var{filename}
469 @opindex pinentry-touch-file
470 By default the filename of the socket gpg-agent is listening for
471 requests is passed to Pinentry, so that it can touch that file before
472 exiting (it does this only in curses mode). This option changes the
473 file passed to Pinentry to @var{filename}. The special name
474 @code{/dev/null} may be used to completely disable this feature. Note
475 that Pinentry will not create that file, it will only change the
476 modification and access time.
479 @item --scdaemon-program @var{filename}
480 @opindex scdaemon-program
481 Use program @var{filename} as the Smartcard daemon. The default is
482 installation dependent and can be shown with the @command{gpgconf}
485 @item --disable-scdaemon
486 @opindex disable-scdaemon
487 Do not make use of the scdaemon tool. This option has the effect of
488 disabling the ability to do smartcard operations. Note, that enabling
489 this option at runtime does not kill an already forked scdaemon.
491 @item --disable-check-own-socket
492 @opindex disable-check-own-socket
493 @command{gpg-agent} employs a periodic self-test to detect a stolen
494 socket. This usually means a second instance of @command{gpg-agent}
495 has taken over the socket and @command{gpg-agent} will then terminate
496 itself. This option may be used to disable this self-test for
499 @item --use-standard-socket
500 @itemx --no-use-standard-socket
501 @itemx --use-standard-socket-p
502 @opindex use-standard-socket
503 @opindex no-use-standard-socket
504 @opindex use-standard-socket-p
505 Since GnuPG 2.1 the standard socket is always used. These options
506 have no more effect. The command @code{gpg-agent
507 --use-standard-socket-p} will thus always return success.
509 @item --display @var{string}
510 @itemx --ttyname @var{string}
511 @itemx --ttytype @var{string}
512 @itemx --lc-ctype @var{string}
513 @itemx --lc-messages @var{string}
514 @itemx --xauthority @var{string}
521 These options are used with the server mode to pass localization
525 @itemx --keep-display
527 @opindex keep-display
528 Ignore requests to change the current @code{tty} or X window system's
529 @code{DISPLAY} variable respectively. This is useful to lock the
530 pinentry to pop up at the @code{tty} or display you started the agent.
533 @anchor{option --extra-socket}
534 @item --extra-socket @var{name}
535 @opindex extra-socket
536 Also listen on native gpg-agent connections on the given socket. The
537 intended use for this extra socket is to setup a Unix domain socket
538 forwarding from a remote machine to this socket on the local machine.
539 A @command{gpg} running on the remote machine may then connect to the
540 local gpg-agent and use its private keys. This allows to decrypt or
541 sign data on a remote machine without exposing the private keys to the
545 @anchor{option --enable-ssh-support}
546 @item --enable-ssh-support
547 @itemx --enable-putty-support
548 @opindex enable-ssh-support
549 @opindex enable-putty-support
551 Enable the OpenSSH Agent protocol.
553 In this mode of operation, the agent does not only implement the
554 gpg-agent protocol, but also the agent protocol used by OpenSSH
555 (through a separate socket). Consequently, it should be possible to use
556 the gpg-agent as a drop-in replacement for the well known ssh-agent.
558 SSH Keys, which are to be used through the agent, need to be added to
559 the gpg-agent initially through the ssh-add utility. When a key is
560 added, ssh-add will ask for the password of the provided key file and
561 send the unprotected key material to the agent; this causes the
562 gpg-agent to ask for a passphrase, which is to be used for encrypting
563 the newly received key and storing it in a gpg-agent specific
566 Once a key has been added to the gpg-agent this way, the gpg-agent
567 will be ready to use the key.
569 Note: in case the gpg-agent receives a signature request, the user might
570 need to be prompted for a passphrase, which is necessary for decrypting
571 the stored key. Since the ssh-agent protocol does not contain a
572 mechanism for telling the agent on which display/terminal it is running,
573 gpg-agent's ssh-support will use the TTY or X display where gpg-agent
574 has been started. To switch this display to the current one, the
575 following command may be used:
578 gpg-connect-agent updatestartuptty /bye
581 Although all GnuPG components try to start the gpg-agent as needed, this
582 is not possible for the ssh support because ssh does not know about it.
583 Thus if no GnuPG tool which accesses the agent has been run, there is no
584 guarantee that ssh is able to use gpg-agent for authentication. To fix
585 this you may start gpg-agent if needed using this simple command:
588 gpg-connect-agent /bye
591 Adding the @option{--verbose} shows the progress of starting the agent.
593 The @option{--enable-putty-support} is only available under Windows
594 and allows the use of gpg-agent with the ssh implementation
595 @command{putty}. This is similar to the regular ssh-agent support but
596 makes use of Windows message queue as required by @command{putty}.
601 All the long options may also be given in the configuration file after
602 stripping off the two leading dashes.
606 @node Agent Configuration
607 @section Configuration
609 There are a few configuration files needed for the operation of the
610 agent. By default they may all be found in the current home directory
611 (@pxref{option --homedir}).
616 @cindex gpg-agent.conf
617 This is the standard configuration file read by @command{gpg-agent} on
618 startup. It may contain any valid long option; the leading
619 two dashes may not be entered and the option may not be abbreviated.
620 This file is also read after a @code{SIGHUP} however only a few
621 options will actually have an effect. This default name may be
622 changed on the command line (@pxref{option --options}).
623 You should backup this file.
626 This is the list of trusted keys. You should backup this file.
628 Comment lines, indicated by a leading hash mark, as well as empty
629 lines are ignored. To mark a key as trusted you need to enter its
630 fingerprint followed by a space and a capital letter @code{S}. Colons
631 may optionally be used to separate the bytes of a fingerprint; this
632 allows to cut and paste the fingerprint from a key listing output. If
633 the line is prefixed with a @code{!} the key is explicitly marked as
636 Here is an example where two keys are marked as ultimately trusted
637 and one as not trusted:
641 # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
642 A6935DD34EF3087973C706FC311AA2CCF733765B S
644 # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
645 DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
647 # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
648 !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
652 Before entering a key into this file, you need to ensure its
653 authenticity. How to do this depends on your organisation; your
654 administrator might have already entered those keys which are deemed
655 trustworthy enough into this file. Places where to look for the
656 fingerprint of a root certificate are letters received from the CA or
657 the website of the CA (after making 100% sure that this is indeed the
658 website of that CA). You may want to consider disallowing interactive
659 updates of this file by using the @xref{option --no-allow-mark-trusted}.
660 It might even be advisable to change the permissions to read-only so
661 that this file can't be changed inadvertently.
663 As a special feature a line @code{include-default} will include a global
664 list of trusted certificates (e.g. @file{@value{SYSCONFDIR}/trustlist.txt}).
665 This global list is also used if the local list is not available.
667 It is possible to add further flags after the @code{S} for use by the
674 Relax checking of some root certificate requirements. As of now this
675 flag allows the use of root certificates with a missing basicConstraints
676 attribute (despite that it is a MUST for CA certificates) and disables
677 CRL checking for the root certificate.
680 If validation of a certificate finally issued by a CA with this flag set
681 fails, try again using the chain validation model.
688 This file is used when support for the secure shell agent protocol has
689 been enabled (@pxref{option --enable-ssh-support}). Only keys present in
690 this file are used in the SSH protocol. You should backup this file.
692 The @command{ssh-add} tool may be used to add new entries to this file;
693 you may also add them manually. Comment lines, indicated by a leading
694 hash mark, as well as empty lines are ignored. An entry starts with
695 optional whitespace, followed by the keygrip of the key given as 40 hex
696 digits, optionally followed by the caching TTL in seconds and another
697 optional field for arbitrary flags. A non-zero TTL overrides the global
698 default as set by @option{--default-cache-ttl-ssh}.
700 The only flag support is @code{confirm}. If this flag is found for a
701 key, each use of the key will pop up a pinentry to confirm the use of
702 that key. The flag is automatically set if a new key was loaded into
703 @code{gpg-agent} using the option @option{-c} of the @code{ssh-add}
706 The keygrip may be prefixed with a @code{!} to disable an entry entry.
708 The following example lists exactly one key. Note that keys available
709 through a OpenPGP smartcard in the active smartcard reader are
710 implicitly added to this list; i.e. there is no need to list them.
714 # Key added on: 2011-07-20 20:38:46
715 # Fingerprint: 5e:8d:c4:ad:e7:af:6e:27:8a:d6:13:e4:79:ad:0b:81
716 34B62F25E277CF13D3C6BCEBFD3F85D08F0A864B 0 confirm
720 @item private-keys-v1.d/
722 This is the directory where gpg-agent stores the private keys. Each
723 key is stored in a file with the name made up of the keygrip and the
724 suffix @file{key}. You should backup all files in this directory
725 and take great care to keep this backup closed away.
730 Note that on larger installations, it is useful to put predefined
731 files into the directory @file{@value{SYSCONFSKELDIR}} so that newly created
732 users start up with a working configuration. For existing users the
733 a small helper script is provided to create these files (@pxref{addgnupghome}).
742 @section Use of some signals.
743 A running @command{gpg-agent} may be controlled by signals, i.e. using
744 the @command{kill} command to send a signal to the process.
746 Here is a list of supported signals:
752 This signal flushes all cached passphrases and if the program has been
753 started with a configuration file, the configuration file is read
754 again. Only certain options are honored: @code{quiet},
755 @code{verbose}, @code{debug}, @code{debug-all}, @code{debug-level},
756 @code{debug-pinentry},
758 @code{pinentry-program},
759 @code{pinentry-invisible-char},
760 @code{default-cache-ttl},
761 @code{max-cache-ttl}, @code{ignore-cache-for-signing},
762 @code{no-allow-external-cache}, @code{allow-emacs-pinentry},
763 @code{no-allow-mark-trusted}, @code{disable-scdaemon}, and
764 @code{disable-check-own-socket}. @code{scdaemon-program} is also
765 supported but due to the current implementation, which calls the
766 scdaemon only once, it is not of much use unless you manually kill the
772 Shuts down the process but waits until all current requests are
773 fulfilled. If the process has received 3 of these signals and requests
774 are still pending, a shutdown is forced.
778 Shuts down the process immediately.
782 Dump internal information to the log file.
786 This signal is used for internal purposes.
797 It is important to set the GPG_TTY environment variable in
798 your login shell, for example in the @file{~/.bashrc} init script:
802 export GPG_TTY=$(tty)
806 If you enabled the Ssh Agent Support, you also need to tell ssh about
807 it by adding this to your init script:
812 if [ "$@{gnupg_SSH_AUTH_SOCK_by:-0@}" -ne $$ ]; then
813 export SSH_AUTH_SOCK="$@{HOME@}/.gnupg/S.gpg-agent.ssh"
824 @section Agent's Assuan Protocol
826 Note: this section does only document the protocol, which is used by
827 GnuPG components; it does not deal with the ssh-agent protocol. To
828 see the full specification of each command, use
831 gpg-connect-agent 'help COMMAND' /bye
835 or just 'help' to list all available commands.
838 The @command{gpg-agent} daemon is started on demand by the GnuPG
841 To identify a key we use a thing called keygrip which is the SHA-1 hash
842 of an canonical encoded S-Expression of the public key as used in
843 Libgcrypt. For the purpose of this interface the keygrip is given as a
844 hex string. The advantage of using this and not the hash of a
845 certificate is that it will be possible to use the same keypair for
846 different protocols, thereby saving space on the token used to keep the
849 The @command{gpg-agent} may send status messages during a command or when
850 returning from a command to inform a client about the progress or result of an
851 operation. For example, the @var{INQUIRE_MAXLEN} status message may be sent
852 during a server inquire to inform the client of the maximum usable length of
853 the inquired data (which should not be exceeded).
856 * Agent PKDECRYPT:: Decrypting a session key
857 * Agent PKSIGN:: Signing a Hash
858 * Agent GENKEY:: Generating a Key
859 * Agent IMPORT:: Importing a Secret Key
860 * Agent EXPORT:: Exporting a Secret Key
861 * Agent ISTRUSTED:: Importing a Root Certificate
862 * Agent GET_PASSPHRASE:: Ask for a passphrase
863 * Agent CLEAR_PASSPHRASE:: Expire a cached passphrase
864 * Agent PRESET_PASSPHRASE:: Set a passphrase for a keygrip
865 * Agent GET_CONFIRMATION:: Ask for confirmation
866 * Agent HAVEKEY:: Check whether a key is available
867 * Agent LEARN:: Register a smartcard
868 * Agent PASSWD:: Change a Passphrase
869 * Agent UPDATESTARTUPTTY:: Change the Standard Display
870 * Agent GETEVENTCOUNTER:: Get the Event Counters
871 * Agent GETINFO:: Return information about the process
872 * Agent OPTION:: Set options for the session
875 @node Agent PKDECRYPT
876 @subsection Decrypting a session key
878 The client asks the server to decrypt a session key. The encrypted
879 session key should have all information needed to select the
880 appropriate secret key or to delegate it to a smartcard.
886 Tell the server about the key to be used for decryption. If this is
887 not used, @command{gpg-agent} may try to figure out the key by trying to
888 decrypt the message with each key available.
894 The agent checks whether this command is allowed and then does an
895 INQUIRY to get the ciphertext the client should then send the cipher
899 S: INQUIRE CIPHERTEXT
905 Please note that the server may send status info lines while reading the
906 data lines from the client. The data send is a SPKI like S-Exp with
912 (<param_name1> <mpi>)
914 (<param_namen> <mpi>)))
917 Where algo is a string with the name of the algorithm; see the libgcrypt
918 documentation for a list of valid algorithms. The number and names of
919 the parameters depend on the algorithm. The agent does return an error
920 if there is an inconsistency.
922 If the decryption was successful the decrypted data is returned by
925 Here is an example session:
929 S: INQUIRE CIPHERTEXT
930 C: D (enc-val elg (a 349324324)
931 C: D (b 3F444677CA)))
933 S: # session key follows
935 S: D (value 1234567890ABCDEF0)
936 S: OK descryption successful
940 The “PADDING” status line is only send if gpg-agent can tell what kind
941 of padding is used. As of now only the value 0 is used to indicate
942 that the padding has been removed.
946 @subsection Signing a Hash
948 The client ask the agent to sign a given hash value. A default key
949 will be chosen if no key has been set. To set a key a client first
956 This can be used multiple times to create multiple signature, the list
957 of keys is reset with the next PKSIGN command or a RESET. The server
958 test whether the key is a valid key to sign something and responds with
962 SETHASH --hash=<name>|<algo> <hexstring>
965 The client can use this command to tell the server about the data <hexstring>
966 (which usually is a hash) to be signed. <algo> is the decimal encoded hash
967 algorithm number as used by Libgcrypt. Either <algo> or --hash=<name>
968 must be given. Valid names for <name> are:
972 The SHA-1 hash algorithm
974 The SHA-256 hash algorithm
976 The RIPE-MD160 hash algorithm
978 The old and broken MD5 hash algorithm
980 A combined hash algorithm as used by the TLS protocol.
984 The actual signing is done using
990 Options are not yet defined, but my later be used to choose among
991 different algorithms. The agent does then some checks, asks for the
992 passphrase and as a result the server returns the signature as an SPKI
993 like S-expression in "D" lines:
998 (<param_name1> <mpi>)
1000 (<param_namen> <mpi>)))
1004 The operation is affected by the option
1007 OPTION use-cache-for-signing=0|1
1010 The default of @code{1} uses the cache. Setting this option to @code{0}
1011 will lead @command{gpg-agent} to ignore the passphrase cache. Note, that there is
1012 also a global command line option for @command{gpg-agent} to globally disable the
1016 Here is an example session:
1024 S: # I did ask the user whether he really wants to sign
1025 S: # I did ask the user for the passphrase
1027 C: D ABCDEF012345678901234
1029 S: # signature follows
1030 S: D (sig-val rsa (s 45435453654612121212))
1036 @subsection Generating a Key
1038 This is used to create a new keypair and store the secret key inside the
1039 active PSE --- which is in most cases a Soft-PSE. An not yet defined
1040 option allows to choose the storage location. To get the secret key out
1041 of the PSE, a special export tool has to be used.
1044 GENKEY [--no-protection] [--preset] [<cache_nonce>]
1047 Invokes the key generation process and the server will then inquire
1048 on the generation parameters, like:
1052 C: D (genkey (rsa (nbits 1024)))
1056 The format of the key parameters which depends on the algorithm is of
1062 (parameter_name_1 ....)
1064 (parameter_name_n ....)))
1067 If everything succeeds, the server returns the *public key* in a SPKI
1068 like S-Expression like this:
1077 Here is an example session:
1082 C: D (genkey (rsa (nbits 1024)))
1085 S: D (rsa (n 326487324683264) (e 10001)))
1090 The @option{--no-protection} option may be used to prevent prompting for a
1091 passphrase to protect the secret key while leaving the secret key unprotected.
1092 The @option{--preset} option may be used to add the passphrase to the cache
1093 using the default cache parameters.
1095 The @option{--inq-passwd} option may be used to create the key with a
1096 supplied passphrase. When used the agent does an inquiry with the
1097 keyword @code{NEWPASSWD} to retrieve that passphrase. This option
1098 takes precedence over @option{--no-protection}; however if the client
1099 sends a empty (zero-length) passphrase, this is identical to
1100 @option{--no-protection}.
1103 @subsection Importing a Secret Key
1105 This operation is not yet supported by GpgAgent. Specialized tools
1106 are to be used for this.
1108 There is no actual need because we can expect that secret keys
1109 created by a 3rd party are stored on a smartcard. If we have
1110 generated the key ourself, we do not need to import it.
1113 @subsection Export a Secret Key
1117 Should be done by an extra tool.
1119 @node Agent ISTRUSTED
1120 @subsection Importing a Root Certificate
1122 Actually we do not import a Root Cert but provide a way to validate
1123 any piece of data by storing its Hash along with a description and
1124 an identifier in the PSE. Here is the interface description:
1127 ISTRUSTED <fingerprint>
1130 Check whether the OpenPGP primary key or the X.509 certificate with the
1131 given fingerprint is an ultimately trusted key or a trusted Root CA
1132 certificate. The fingerprint should be given as a hexstring (without
1133 any blanks or colons or whatever in between) and may be left padded with
1134 00 in case of an MD5 fingerprint. GPGAgent will answer with:
1140 The key is in the table of trusted keys.
1143 ERR 304 (Not Trusted)
1146 The key is not in this table.
1148 Gpg needs the entire list of trusted keys to maintain the web of
1149 trust; the following command is therefore quite helpful:
1155 GpgAgent returns a list of trusted keys line by line:
1158 S: D 000000001234454556565656677878AF2F1ECCFF P
1159 S: D 340387563485634856435645634856438576457A P
1160 S: D FEDC6532453745367FD83474357495743757435D S
1164 The first item on a line is the hexified fingerprint where MD5
1165 fingerprints are @code{00} padded to the left and the second item is a
1166 flag to indicate the type of key (so that gpg is able to only take care
1167 of PGP keys). P = OpenPGP, S = S/MIME. A client should ignore the rest
1168 of the line, so that we can extend the format in the future.
1170 Finally a client should be able to mark a key as trusted:
1173 MARKTRUSTED @var{fingerprint} "P"|"S"
1176 The server will then pop up a window to ask the user whether she
1177 really trusts this key. For this it will probably ask for a text to
1178 be displayed like this:
1181 S: INQUIRE TRUSTDESC
1182 C: D Do you trust the key with the fingerprint @@FPR@@
1183 C: D bla fasel blurb.
1188 Known sequences with the pattern @@foo@@ are replaced according to this
1193 Format the fingerprint according to gpg rules for a v3 keys.
1195 Format the fingerprint according to gpg rules for a v4 keys.
1197 Choose an appropriate format to format the fingerprint.
1199 Replaced by a single @code{@@}
1202 @node Agent GET_PASSPHRASE
1203 @subsection Ask for a passphrase
1205 This function is usually used to ask for a passphrase to be used for
1206 symmetric encryption, but may also be used by programs which need
1207 special handling of passphrases. This command uses a syntax which helps
1208 clients to use the agent with minimum effort.
1211 GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]] \
1212 [--qualitybar] @var{cache_id} \
1213 [@var{error_message} @var{prompt} @var{description}]
1216 @var{cache_id} is expected to be a string used to identify a cached
1217 passphrase. Use a @code{X} to bypass the cache. With no other
1218 arguments the agent returns a cached passphrase or an error. By
1219 convention either the hexified fingerprint of the key shall be used for
1220 @var{cache_id} or an arbitrary string prefixed with the name of the
1221 calling application and a colon: Like @code{gpg:somestring}.
1223 @var{error_message} is either a single @code{X} for no error message or
1224 a string to be shown as an error message like (e.g. "invalid
1225 passphrase"). Blanks must be percent escaped or replaced by @code{+}'.
1227 @var{prompt} is either a single @code{X} for a default prompt or the
1228 text to be shown as the prompt. Blanks must be percent escaped or
1229 replaced by @code{+}.
1231 @var{description} is a text shown above the entry field. Blanks must be
1232 percent escaped or replaced by @code{+}.
1234 The agent either returns with an error or with a OK followed by the hex
1235 encoded passphrase. Note that the length of the strings is implicitly
1236 limited by the maximum length of a command. If the option
1237 @option{--data} is used, the passphrase is not returned on the OK line
1238 but by regular data lines; this is the preferred method.
1240 If the option @option{--check} is used, the standard passphrase
1241 constraints checks are applied. A check is not done if the passphrase
1242 has been found in the cache.
1244 If the option @option{--no-ask} is used and the passphrase is not in the
1245 cache the user will not be asked to enter a passphrase but the error
1246 code @code{GPG_ERR_NO_DATA} is returned.
1248 If the option @option{--qualitybar} is used and a minimum passphrase
1249 length has been configured, a visual indication of the entered
1250 passphrase quality is shown.
1253 CLEAR_PASSPHRASE @var{cache_id}
1256 may be used to invalidate the cache entry for a passphrase. The
1257 function returns with OK even when there is no cached passphrase.
1261 @node Agent CLEAR_PASSPHRASE
1262 @subsection Remove a cached passphrase
1264 Use this command to remove a cached passphrase.
1267 CLEAR_PASSPHRASE [--mode=normal] <cache_id>
1270 The @option{--mode=normal} option can be used to clear a @var{cache_id} that
1271 was set by gpg-agent.
1274 @node Agent PRESET_PASSPHRASE
1275 @subsection Set a passphrase for a keygrip
1277 This command adds a passphrase to the cache for the specified @var{keygrip}.
1280 PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]
1283 The passphrase is a hexidecimal string when specified. When not specified, the
1284 passphrase will be retrieved from the pinentry module unless the
1285 @option{--inquire} option was specified in which case the passphrase will be
1286 retrieved from the client.
1288 The @var{timeout} parameter keeps the passphrase cached for the specified
1289 number of seconds. A value of @code{-1} means infinate while @code{0} means
1290 the default (currently only a timeout of -1 is allowed, which means to never
1294 @node Agent GET_CONFIRMATION
1295 @subsection Ask for confirmation
1297 This command may be used to ask for a simple confirmation by
1298 presenting a text and 2 buttons: Okay and Cancel.
1301 GET_CONFIRMATION @var{description}
1304 @var{description}is displayed along with a Okay and Cancel
1305 button. Blanks must be percent escaped or replaced by @code{+}. A
1306 @code{X} may be used to display confirmation dialog with a default
1309 The agent either returns with an error or with a OK. Note, that the
1310 length of @var{description} is implicitly limited by the maximum
1311 length of a command.
1316 @subsection Check whether a key is available
1318 This can be used to see whether a secret key is available. It does
1319 not return any information on whether the key is somehow protected.
1322 HAVEKEY @var{keygrips}
1325 The agent answers either with OK or @code{No_Secret_Key} (208). The
1326 caller may want to check for other error codes as well. More than one
1327 keygrip may be given. In this case the command returns success if at
1328 least one of the keygrips corresponds to an available secret key.
1332 @subsection Register a smartcard
1338 This command is used to register a smartcard. With the --send
1339 option given the certificates are send back.
1343 @subsection Change a Passphrase
1346 PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] @var{keygrip}
1349 This command is used to interactively change the passphrase of the key
1350 identified by the hex string @var{keygrip}. The @option{--preset}
1351 option may be used to add the new passphrase to the cache using the
1352 default cache parameters.
1355 @node Agent UPDATESTARTUPTTY
1356 @subsection Change the standard display
1362 Set the startup TTY and X-DISPLAY variables to the values of this
1363 session. This command is useful to direct future pinentry invocations
1364 to another screen. It is only required because there is no way in the
1365 ssh-agent protocol to convey this information.
1368 @node Agent GETEVENTCOUNTER
1369 @subsection Get the Event Counters
1375 This function return one status line with the current values of the
1376 event counters. The event counters are useful to avoid polling by
1377 delaying a poll until something has changed. The values are decimal
1378 numbers in the range @code{0} to @code{UINT_MAX} and wrapping around to
1379 0. The actual values should not be relied upon; they shall only be used
1382 The currently defined counters are are:
1385 Incremented with any change of any of the other counters.
1387 Incremented for added or removed private keys.
1389 Incremented for changes of the card readers stati.
1393 @subsection Return information about the process
1395 This is a multipurpose function to return a variety of information.
1401 The value of @var{what} specifies the kind of information returned:
1404 Return the version of the program.
1406 Return the process id of the process.
1408 Return the name of the socket used to connect the agent.
1409 @item ssh_socket_name
1410 Return the name of the socket used for SSH connections. If SSH support
1411 has not been enabled the error @code{GPG_ERR_NO_DATA} will be returned.
1415 @subsection Set options for the session
1417 Here is a list of session options which are not yet described with
1418 other commands. The general syntax for an Assuan option is:
1421 OPTION @var{key}=@var{value}
1425 Supported @var{key}s are:
1428 @item agent-awareness
1429 This may be used to tell gpg-agent of which gpg-agent version the
1430 client is aware of. gpg-agent uses this information to enable
1431 features which might break older clients.
1434 Change the session's environment to be used for the
1435 Pinentry. Valid values are:
1439 Delete envvar @var{name}
1441 Set envvar @var{name} to the empty string
1442 @item @var{name}=@var{value}
1443 Set envvar @var{name} to the string @var{value}.
1446 @item use-cache-for-signing
1447 See Assuan command @code{PKSIGN}.
1449 @item allow-pinentry-notify
1450 This does not need any value. It is used to enable the
1451 PINENTRY_LAUNCHED inquiry.
1454 This option is used to change the operation mode of the pinentry. The
1455 following values are defined:
1459 This is the default mode which pops up a pinentry as needed.
1462 Instead of popping up a pinentry, return the error code
1463 @code{GPG_ERR_CANCELED}.
1466 Instead of popping up a pinentry, return the error code
1467 @code{GPG_ERR_NO_PIN_ENTRY}.
1470 Use a loopback pinentry. This fakes a pinentry by using inquiries
1471 back to the caller to ask for a passphrase. This option may only be
1472 set if the agent has been configured for that.
1473 To disable this feature use @xref{option --no-allow-loopback-pinentry}.
1477 @item cache-ttl-opt-preset
1478 This option sets the cache TTL for new entries created by GENKEY and
1479 PASSWD commands when using the @option{--preset} option. It it is not
1480 used a default value is used.
1483 Instead of using the standard S2K count (which is computed on the
1484 fly), the given S2K count is used for new keys or when changing the
1485 passphrase of a key. Values below 65536 are considered to be 0. This
1486 option is valid for the entire session or until reset to 0. This
1487 option is useful if the key is later used on boxes which are either
1488 much slower or faster than the actual box.
1497 @command{gpg-connect-agent}(1),
1498 @command{scdaemon}(1)
1500 @include see-also-note.texi