Imported Upstream version 2.1.4
[platform/upstream/gpg2.git] / doc / gpg-agent.texi
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.
4
5 @c Note that we use this texinfo file for all versions of GnuPG:
6 @c 2.0 and 2.1.  The macro "gpgtwoone" controls parts which are only
7 @c valid for GnuPG 2.1 and later.
8
9
10 @node Invoking GPG-AGENT
11 @chapter Invoking GPG-AGENT
12 @cindex GPG-AGENT command options
13 @cindex command options
14 @cindex options, GPG-AGENT command
15
16 @manpage gpg-agent.1
17 @ifset manverb
18 .B gpg-agent
19 \- Secret key management for GnuPG
20 @end ifset
21
22 @mansect synopsis
23 @ifset manverb
24 .B  gpg-agent
25 .RB [ \-\-homedir
26 .IR dir ]
27 .RB [ \-\-options
28 .IR file ]
29 .RI [ options ]
30 .br
31 .B  gpg-agent
32 .RB [ \-\-homedir
33 .IR dir ]
34 .RB [ \-\-options
35 .IR file ]
36 .RI [ options ]
37 .B  \-\-server
38 .br
39 .B  gpg-agent
40 .RB [ \-\-homedir
41 .IR dir ]
42 .RB [ \-\-options
43 .IR file ]
44 .RI [ options ]
45 .B  \-\-daemon
46 .RI [ command_line ]
47 @end ifset
48
49 @mansect description
50 @command{gpg-agent} is a daemon to manage secret (private) keys
51 independently from any protocol.  It is used as a backend for
52 @command{gpg} and @command{gpgsm} as well as for a couple of other
53 utilities.
54
55 @ifset gpgtwoone
56 The agent is automatically started on demand by @command{gpg},
57 @command{gpgsm}, @command{gpgconf}, or @command{gpg-connect-agent}.
58 Thus there is no reason to start it manually.  In case you want to use
59 the included Secure Shell Agent you may start the agent using:
60
61 @example
62 gpg-connect-agent /bye
63 @end example
64 @end ifset
65
66 @ifclear gpgtwoone
67 @noindent
68 The usual way to run the agent is from the @code{~/.xsession} file:
69
70 @example
71 eval $(gpg-agent --daemon)
72 @end example
73 @noindent
74 If you don't use an X server, you can also put this into your regular
75 startup file @code{~/.profile} or @code{.bash_profile}.  It is best not
76 to run multiple instance of the @command{gpg-agent}, so you should make
77 sure that only one is running: @command{gpg-agent} uses an environment
78 variable to inform clients about the communication parameters. You can
79 write the content of this environment variable to a file so that you can
80 test for a running agent.  Here is an example using Bourne shell syntax:
81
82 @smallexample
83 gpg-agent --daemon --enable-ssh-support \
84           --write-env-file "$@{HOME@}/.gpg-agent-info"
85 @end smallexample
86
87 This code should only be run once per user session to initially fire up
88 the agent.  In the example the optional support for the included Secure
89 Shell agent is enabled and the information about the agent is written to
90 a file in the HOME directory.  Note that by running gpg-agent without
91 arguments you may test whether an agent is already running; however such
92 a test may lead to a race condition, thus it is not suggested.
93
94 @noindent
95 The second script needs to be run for each interactive session:
96
97 @smallexample
98 if [ -f "$@{HOME@}/.gpg-agent-info" ]; then
99   . "$@{HOME@}/.gpg-agent-info"
100   export GPG_AGENT_INFO
101   export SSH_AUTH_SOCK
102 fi
103 @end smallexample
104
105 @noindent
106 It reads the data out of the file and exports the variables.  If you
107 don't use Secure Shell, you don't need the last two export statements.
108 @end ifclear
109
110 @noindent
111 You should always add the following lines to your @code{.bashrc} or
112 whatever initialization file is used for all shell invocations:
113
114 @smallexample
115 GPG_TTY=$(tty)
116 export GPG_TTY
117 @end smallexample
118
119 @noindent
120 It is important that this environment variable always reflects the
121 output of the @code{tty} command.  For W32 systems this option is not
122 required.
123
124 Please make sure that a proper pinentry program has been installed
125 under the default filename (which is system dependent) or use the
126 option @option{pinentry-program} to specify the full name of that program.
127 It is often useful to install a symbolic link from the actual used
128 pinentry (e.g. @file{/usr/bin/pinentry-gtk}) to the expected
129 one (e.g. @file{/usr/bin/pinentry}).
130
131 @manpause
132 @noindent
133 @xref{Option Index},for an index to @command{GPG-AGENT}'s commands and options.
134 @mancont
135
136 @menu
137 * Agent Commands::      List of all commands.
138 * Agent Options::       List of all options.
139 * Agent Configuration:: Configuration files.
140 * Agent Signals::       Use of some signals.
141 * Agent Examples::      Some usage examples.
142 * Agent Protocol::      The protocol the agent uses.
143 @end menu
144
145 @mansect commands
146 @node Agent Commands
147 @section Commands
148
149 Commands are not distinguished from options except for the fact that
150 only one command is allowed.
151
152 @table @gnupgtabopt
153 @item --version
154 @opindex version
155 Print the program version and licensing information.  Note that you cannot
156 abbreviate this command.
157
158 @item --help
159 @itemx -h
160 @opindex help
161 Print a usage message summarizing the most useful command-line options.
162 Note that you cannot abbreviate this command.
163
164 @item --dump-options
165 @opindex dump-options
166 Print a list of all available options and commands.  Note that you cannot
167 abbreviate this command.
168
169 @item --server
170 @opindex server
171 Run in server mode and wait for commands on the @code{stdin}.  The
172 default mode is to create a socket and listen for commands there.
173
174 @item --daemon [@var{command line}]
175 @opindex daemon
176 Start the gpg-agent as a daemon; that is, detach it from the console
177 and run it in the background.
178 @ifclear gpgtwoone
179 Because @command{gpg-agent} prints out
180 important information required for further use, a common way of
181 invoking gpg-agent is: @code{eval $(gpg-agent --daemon)} to setup the
182 environment variables.  The option @option{--write-env-file} is
183 another way commonly used to do this.
184 @end ifclear
185 Yet another way is creating
186 a new process as a child of gpg-agent: @code{gpg-agent --daemon
187 /bin/sh}.  This way you get a new shell with the environment setup
188 properly; if you exit from this shell, gpg-agent terminates as well.
189 @end table
190
191 @mansect options
192 @node Agent Options
193 @section Option Summary
194
195 @table @gnupgtabopt
196
197 @anchor{option --options}
198 @item --options @var{file}
199 @opindex options
200 Reads configuration from @var{file} instead of from the default
201 per-user configuration file.  The default configuration file is named
202 @file{gpg-agent.conf} and expected in the @file{.gnupg} directory directly
203 below the home directory of the user.
204
205 @anchor{option --homedir}
206 @include opt-homedir.texi
207
208
209 @item -v
210 @item --verbose
211 @opindex verbose
212 Outputs additional information while running.
213 You can increase the verbosity by giving several
214 verbose commands to @command{gpgsm}, such as @samp{-vv}.
215
216 @item -q
217 @item --quiet
218 @opindex quiet
219 Try to be as quiet as possible.
220
221 @item --batch
222 @opindex batch
223 Don't invoke a pinentry or do any other thing requiring human interaction.
224
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
229 1970.
230
231 @item --debug-level @var{level}
232 @opindex debug-level
233 Select the debug level for investigating problems. @var{level} may be
234 a numeric value or a keyword:
235
236 @table @code
237 @item none
238 No debugging at all.  A value of less than 1 may be used instead of
239 the keyword.
240 @item basic
241 Some basic debug messages.  A value between 1 and 2 may be used
242 instead of the keyword.
243 @item advanced
244 More verbose debug messages.  A value between 3 and 5 may be used
245 instead of the keyword.
246 @item expert
247 Even more detailed messages.  A value between 6 and 8 may be used
248 instead of the keyword.
249 @item guru
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.
253 @end table
254
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.
258
259 @item --debug @var{flags}
260 @opindex debug
261 This option is only useful for debugging and the behaviour may change at
262 any time without notice.  FLAGS are bit encoded and may be given in
263 usual C-Syntax. The currently defined bits are:
264
265 @table @code
266 @item 0  (1)
267 X.509 or OpenPGP protocol related data
268 @item 1  (2)
269 values of big number integers
270 @item 2  (4)
271 low level crypto operations
272 @item 5  (32)
273 memory allocation
274 @item 6  (64)
275 caching
276 @item 7  (128)
277 show memory statistics.
278 @item 9  (512)
279 write hashed data to files named @code{dbgmd-000*}
280 @item 10 (1024)
281 trace Assuan protocol
282 @item 12 (4096)
283 bypass all certificate validation
284 @end table
285
286 @item --debug-all
287 @opindex debug-all
288 Same as @code{--debug=0xffffffff}
289
290 @item --debug-wait @var{n}
291 @opindex debug-wait
292 When running in server mode, wait @var{n} seconds before entering the
293 actual processing loop and print the pid.  This gives time to attach a
294 debugger.
295
296 @item --debug-quick-random
297 @opindex debug-quick-random
298 This option inhibits the use of the very secure random quality level
299 (Libgcrypt’s @code{GCRY_VERY_STRONG_RANDOM}) and degrades all request
300 down to standard random quality.  It is only used for testing and
301 shall not be used for any production quality keys.  This option is
302 only effective when given on the command line.
303
304 @item --debug-pinentry
305 @opindex debug-pinentry
306 This option enables extra debug information pertaining to the
307 Pinentry.  As of now it is only useful when used along with
308 @code{--debug 1024}.
309
310 @item --no-detach
311 @opindex no-detach
312 Don't detach the process from the console.  This is mainly useful for
313 debugging.
314
315 @item -s
316 @itemx --sh
317 @itemx -c
318 @itemx --csh
319 @opindex sh
320 @opindex csh
321 Format the info output in daemon mode for use with the standard Bourne
322 shell or the C-shell respectively.  The default is to guess it based on
323 the environment variable @code{SHELL} which is correct in almost all
324 cases.
325
326 @ifclear gpgtwoone
327 @item --write-env-file @var{file}
328 @opindex write-env-file
329 Often it is required to connect to the agent from a process not being an
330 inferior of @command{gpg-agent} and thus the environment variable with
331 the socket name is not available.  To help setting up those variables in
332 other sessions, this option may be used to write the information into
333 @var{file}.  If @var{file} is not specified the default name
334 @file{$@{HOME@}/.gpg-agent-info} will be used.  The format is suitable
335 to be evaluated by a Bourne shell like in this simple example:
336
337 @example
338 eval $(cat @var{file})
339 eval $(cut -d= -f 1 < @var{file} | xargs echo export)
340 @end example
341 @end ifclear
342
343
344 @item --no-grab
345 @opindex no-grab
346 Tell the pinentry not to grab the keyboard and mouse.  This option
347 should in general not be used to avoid X-sniffing attacks.
348
349 @anchor{option --log-file}
350 @item --log-file @var{file}
351 @opindex log-file
352 Append all logging output to @var{file}.  This is very helpful in seeing
353 what the agent actually does.  If neither a log file nor a log file
354 descriptor has been set on a Windows platform, the Registry entry
355 @code{HKCU\Software\GNU\GnuPG:DefaultLogFile}, if set, is used to specify
356 the logging output.
357
358
359 @anchor{option --no-allow-mark-trusted}
360 @item --no-allow-mark-trusted
361 @opindex no-allow-mark-trusted
362 Do not allow clients to mark keys as trusted, i.e. put them into the
363 @file{trustlist.txt} file.  This makes it harder for users to inadvertently
364 accept Root-CA keys.
365
366 @anchor{option --allow-preset-passphrase}
367 @item --allow-preset-passphrase
368 @opindex allow-preset-passphrase
369 This option allows the use of @command{gpg-preset-passphrase} to seed the
370 internal cache of @command{gpg-agent} with passphrases.
371
372 @ifset gpgtwoone
373 @anchor{option --allow-loopback-pinentry}
374 @item --allow-loopback-pinentry
375 @opindex allow-loopback-pinentry
376 Allow clients to use the loopback pinentry features; see the option
377 @option{pinentry-mode} for details.
378 @end ifset
379
380 @ifset gpgtwoone
381 @item --no-allow-external-cache
382 @opindex no-allow-external-cache
383 Tell Pinentry not to enable features which use an external cache for
384 passphrases.
385
386 Some desktop environments prefer to unlock all
387 credentials with one master password and may have installed a Pinentry
388 which employs an additional external cache to implement such a policy.
389 By using this option the Pinentry is advised not to make use of such a
390 cache and instead always ask the user for the requested passphrase.
391 @end ifset
392
393 @item --ignore-cache-for-signing
394 @opindex ignore-cache-for-signing
395 This option will let @command{gpg-agent} bypass the passphrase cache for all
396 signing operation.  Note that there is also a per-session option to
397 control this behaviour but this command line option takes precedence.
398
399 @item --default-cache-ttl @var{n}
400 @opindex default-cache-ttl
401 Set the time a cache entry is valid to @var{n} seconds.  The default is
402 600 seconds.
403
404 @item --default-cache-ttl-ssh @var{n}
405 @opindex default-cache-ttl
406 Set the time a cache entry used for SSH keys is valid to @var{n}
407 seconds.  The default is 1800 seconds.
408
409 @item --max-cache-ttl @var{n}
410 @opindex max-cache-ttl
411 Set the maximum time a cache entry is valid to @var{n} seconds.  After
412 this time a cache entry will be expired even if it has been accessed
413 recently or has been set using @command{gpg-preset-passphrase}.  The
414 default is 2 hours (7200 seconds).
415
416 @item --max-cache-ttl-ssh @var{n}
417 @opindex max-cache-ttl-ssh
418 Set the maximum time a cache entry used for SSH keys is valid to
419 @var{n} seconds.  After this time a cache entry will be expired even
420 if it has been accessed recently or has been set using
421 @command{gpg-preset-passphrase}.  The default is 2 hours (7200
422 seconds).
423
424 @item --enforce-passphrase-constraints
425 @opindex enforce-passphrase-constraints
426 Enforce the passphrase constraints by not allowing the user to bypass
427 them using the ``Take it anyway'' button.
428
429 @item --min-passphrase-len @var{n}
430 @opindex min-passphrase-len
431 Set the minimal length of a passphrase.  When entering a new passphrase
432 shorter than this value a warning will be displayed.  Defaults to 8.
433
434 @item --min-passphrase-nonalpha @var{n}
435 @opindex min-passphrase-nonalpha
436 Set the minimal number of digits or special characters required in a
437 passphrase.  When entering a new passphrase with less than this number
438 of digits or special characters a warning will be displayed.  Defaults
439 to 1.
440
441 @item --check-passphrase-pattern @var{file}
442 @opindex check-passphrase-pattern
443 Check the passphrase against the pattern given in @var{file}.  When
444 entering a new passphrase matching one of these pattern a warning will
445 be displayed. @var{file} should be an absolute filename.  The default is
446 not to use any pattern file.
447
448 Security note: It is known that checking a passphrase against a list of
449 pattern or even against a complete dictionary is not very effective to
450 enforce good passphrases.  Users will soon figure up ways to bypass such
451 a policy.  A better policy is to educate users on good security
452 behavior and optionally to run a passphrase cracker regularly on all
453 users passphrases to catch the very simple ones.
454
455 @item --max-passphrase-days @var{n}
456 @opindex max-passphrase-days
457 Ask the user to change the passphrase if @var{n} days have passed since
458 the last change.  With @option{--enforce-passphrase-constraints} set the
459 user may not bypass this check.
460
461 @item --enable-passphrase-history
462 @opindex enable-passphrase-history
463 This option does nothing yet.
464
465 @item --pinentry-program @var{filename}
466 @opindex pinentry-program
467 Use program @var{filename} as the PIN entry.  The default is
468 installation dependent.  With the default configuration the name of
469 the default pinentry is @file{pinentry}; if that file does not exist
470 but a @file{pinentry-basic} exist the latter is used.
471
472 @item --pinentry-touch-file @var{filename}
473 @opindex pinentry-touch-file
474 By default the filename of the socket gpg-agent is listening for
475 requests is passed to Pinentry, so that it can touch that file before
476 exiting (it does this only in curses mode).  This option changes the
477 file passed to Pinentry to @var{filename}.  The special name
478 @code{/dev/null} may be used to completely disable this feature.  Note
479 that Pinentry will not create that file, it will only change the
480 modification and access time.
481
482
483 @item --scdaemon-program @var{filename}
484 @opindex scdaemon-program
485 Use program @var{filename} as the Smartcard daemon.  The default is
486 installation dependent and can be shown with the @command{gpgconf}
487 command.
488
489 @item --disable-scdaemon
490 @opindex disable-scdaemon
491 Do not make use of the scdaemon tool.  This option has the effect of
492 disabling the ability to do smartcard operations.  Note, that enabling
493 this option at runtime does not kill an already forked scdaemon.
494
495 @ifset gpgtwoone
496 @item --disable-check-own-socket
497 @opindex disable-check-own-socket
498 @command{gpg-agent} employs a periodic self-test to detect a stolen
499 socket.  This usually means a second instance of @command{gpg-agent}
500 has taken over the socket and @command{gpg-agent} will then terminate
501 itself.  This option may be used to disable this self-test for
502 debugging purposes.
503 @end ifset
504
505 @item --use-standard-socket
506 @itemx --no-use-standard-socket
507 @itemx --use-standard-socket-p
508 @opindex use-standard-socket
509 @opindex no-use-standard-socket
510 @opindex use-standard-socket-p
511 @ifset gpgtwoone
512 Since GnuPG 2.1 the standard socket is always used.  These options
513 have no more effect.  The command @code{gpg-agent
514 --use-standard-socket-p} will thus always return success.
515 @end ifset
516 @ifclear gpgtwoone
517 By enabling this option @command{gpg-agent} will listen on the socket
518 named @file{S.gpg-agent}, located in the home directory, and not create
519 a random socket below a temporary directory.  Tools connecting to
520 @command{gpg-agent} should first try to connect to the socket given in
521 environment variable @var{GPG_AGENT_INFO} and then fall back to this
522 socket.  This option may not be used if the home directory is mounted on
523 a remote file system which does not support special files like fifos or
524 sockets.
525
526 Note, that @option{--use-standard-socket} is the default on
527 Windows systems.
528
529 The default may be changed at build time.  It is
530 possible to test at runtime whether the agent has been configured for
531 use with the standard socket by issuing the command @command{gpg-agent
532 --use-standard-socket-p} which returns success if the standard socket
533 option has been enabled.
534 @end ifclear
535
536 @item --display @var{string}
537 @itemx --ttyname @var{string}
538 @itemx --ttytype @var{string}
539 @itemx --lc-ctype @var{string}
540 @itemx --lc-messages @var{string}
541 @itemx --xauthority @var{string}
542 @opindex display
543 @opindex ttyname
544 @opindex ttytype
545 @opindex lc-ctype
546 @opindex lc-messages
547 @opindex xauthority
548 These options are used with the server mode to pass localization
549 information.
550
551 @item --keep-tty
552 @itemx --keep-display
553 @opindex keep-tty
554 @opindex keep-display
555 Ignore requests to change the current @code{tty} or X window system's
556 @code{DISPLAY} variable respectively.  This is useful to lock the
557 pinentry to pop up at the @code{tty} or display you started the agent.
558
559
560 @anchor{option --extra-socket}
561 @item --extra-socket @var{name}
562 @opindex extra-socket
563 Also listen on native gpg-agent connections on the given socket.  The
564 intended use for this extra socket is to setup a Unix domain socket
565 forwarding from a remote machine to this socket on the local machine.
566 A @command{gpg} running on the remote machine may then connect to the
567 local gpg-agent and use its private keys.  This allows to decrypt or
568 sign data on a remote machine without exposing the private keys to the
569 remote machine.
570
571
572 @anchor{option --enable-ssh-support}
573 @item --enable-ssh-support
574 @opindex enable-ssh-support
575
576 Enable the OpenSSH Agent protocol.
577
578 In this mode of operation, the agent does not only implement the
579 gpg-agent protocol, but also the agent protocol used by OpenSSH
580 (through a separate socket).  Consequently, it should be possible to use
581 the gpg-agent as a drop-in replacement for the well known ssh-agent.
582
583 SSH Keys, which are to be used through the agent, need to be added to
584 the gpg-agent initially through the ssh-add utility.  When a key is
585 added, ssh-add will ask for the password of the provided key file and
586 send the unprotected key material to the agent; this causes the
587 gpg-agent to ask for a passphrase, which is to be used for encrypting
588 the newly received key and storing it in a gpg-agent specific
589 directory.
590
591 Once a key has been added to the gpg-agent this way, the gpg-agent
592 will be ready to use the key.
593
594 Note: in case the gpg-agent receives a signature request, the user might
595 need to be prompted for a passphrase, which is necessary for decrypting
596 the stored key.  Since the ssh-agent protocol does not contain a
597 mechanism for telling the agent on which display/terminal it is running,
598 gpg-agent's ssh-support will use the TTY or X display where gpg-agent
599 has been started.  To switch this display to the current one, the
600 following command may be used:
601
602 @smallexample
603 gpg-connect-agent updatestartuptty /bye
604 @end smallexample
605
606 Although all GnuPG components try to start the gpg-agent as needed, this
607 is not possible for the ssh support because ssh does not know about it.
608 Thus if no GnuPG tool which accesses the agent has been run, there is no
609 guarantee that ssh is able to use gpg-agent for authentication.  To fix
610 this you may start gpg-agent if needed using this simple command:
611
612 @smallexample
613 gpg-connect-agent /bye
614 @end smallexample
615
616 Adding the @option{--verbose} shows the progress of starting the agent.
617
618 @end table
619
620 All the long options may also be given in the configuration file after
621 stripping off the two leading dashes.
622
623
624 @mansect files
625 @node Agent Configuration
626 @section Configuration
627
628 There are a few configuration files needed for the operation of the
629 agent. By default they may all be found in the current home directory
630 (@pxref{option --homedir}).
631
632 @table @file
633
634 @item gpg-agent.conf
635 @cindex gpg-agent.conf
636   This is the standard configuration file read by @command{gpg-agent} on
637   startup.  It may contain any valid long option; the leading
638   two dashes may not be entered and the option may not be abbreviated.
639   This file is also read after a @code{SIGHUP} however only a few
640   options will actually have an effect.  This default name may be
641   changed on the command line (@pxref{option --options}).
642   You should backup this file.
643
644 @item trustlist.txt
645   This is the list of trusted keys.  You should backup this file.
646
647   Comment lines, indicated by a leading hash mark, as well as empty
648   lines are ignored.  To mark a key as trusted you need to enter its
649   fingerprint followed by a space and a capital letter @code{S}.  Colons
650   may optionally be used to separate the bytes of a fingerprint; this
651   allows to cut and paste the fingerprint from a key listing output.  If
652   the line is prefixed with a @code{!} the key is explicitly marked as
653   not trusted.
654
655   Here is an example where two keys are marked as ultimately trusted
656   and one as not trusted:
657
658   @cartouche
659   @smallexample
660   # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
661   A6935DD34EF3087973C706FC311AA2CCF733765B S
662
663   # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
664   DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
665
666   # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
667   !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
668   @end smallexample
669   @end cartouche
670
671 Before entering a key into this file, you need to ensure its
672 authenticity.  How to do this depends on your organisation; your
673 administrator might have already entered those keys which are deemed
674 trustworthy enough into this file.  Places where to look for the
675 fingerprint of a root certificate are letters received from the CA or
676 the website of the CA (after making 100% sure that this is indeed the
677 website of that CA).  You may want to consider disallowing interactive
678 updates of this file by using the @xref{option --no-allow-mark-trusted}.
679 It might even be advisable to change the permissions to read-only so
680 that this file can't be changed inadvertently.
681
682 As a special feature a line @code{include-default} will include a global
683 list of trusted certificates (e.g. @file{/etc/gnupg/trustlist.txt}).
684 This global list is also used if the local list is not available.
685
686 It is possible to add further flags after the @code{S} for use by the
687 caller:
688
689 @table @code
690
691 @item relax
692 @cindex relax
693 Relax checking of some root certificate requirements.  As of now this
694 flag allows the use of root certificates with a missing basicConstraints
695 attribute (despite that it is a MUST for CA certificates) and disables
696 CRL checking for the root certificate.
697
698 @item cm
699 If validation of a certificate finally issued by a CA with this flag set
700 fails, try again using the chain validation model.
701
702 @end table
703
704
705 @item sshcontrol
706 @cindex sshcontrol
707 This file is used when support for the secure shell agent protocol has
708 been enabled (@pxref{option --enable-ssh-support}). Only keys present in
709 this file are used in the SSH protocol.  You should backup this file.
710
711 The @command{ssh-add} tool may be used to add new entries to this file;
712 you may also add them manually.  Comment lines, indicated by a leading
713 hash mark, as well as empty lines are ignored.  An entry starts with
714 optional whitespace, followed by the keygrip of the key given as 40 hex
715 digits, optionally followed by the caching TTL in seconds and another
716 optional field for arbitrary flags.  A non-zero TTL overrides the global
717 default as set by @option{--default-cache-ttl-ssh}.
718
719 The only flag support is @code{confirm}.  If this flag is found for a
720 key, each use of the key will pop up a pinentry to confirm the use of
721 that key.  The flag is automatically set if a new key was loaded into
722 @code{gpg-agent} using the option @option{-c} of the @code{ssh-add}
723 command.
724
725 The keygrip may be prefixed with a @code{!} to disable an entry entry.
726
727 The following example lists exactly one key.  Note that keys available
728 through a OpenPGP smartcard in the active smartcard reader are
729 implicitly added to this list; i.e. there is no need to list them.
730
731 @cartouche
732 @smallexample
733        # Key added on: 2011-07-20 20:38:46
734        # Fingerprint:  5e:8d:c4:ad:e7:af:6e:27:8a:d6:13:e4:79:ad:0b:81
735        34B62F25E277CF13D3C6BCEBFD3F85D08F0A864B 0 confirm
736 @end smallexample
737 @end cartouche
738
739 @item private-keys-v1.d/
740
741   This is the directory where gpg-agent stores the private keys.  Each
742   key is stored in a file with the name made up of the keygrip and the
743   suffix @file{key}.  You should backup all files in this directory
744   and take great care to keep this backup closed away.
745
746
747 @end table
748
749 Note that on larger installations, it is useful to put predefined
750 files into the directory @file{/etc/skel/.gnupg/} so that newly created
751 users start up with a working configuration.  For existing users the
752 a small helper script is provided to create these files (@pxref{addgnupghome}).
753
754
755
756 @c
757 @c Agent Signals
758 @c
759 @mansect signals
760 @node Agent Signals
761 @section Use of some signals.
762 A running @command{gpg-agent} may be controlled by signals, i.e. using
763 the @command{kill} command to send a signal to the process.
764
765 Here is a list of supported signals:
766
767 @table @gnupgtabopt
768
769 @item SIGHUP
770 @cpindex SIGHUP
771 This signal flushes all cached passphrases and if the program has been
772 started with a configuration file, the configuration file is read
773 again.  Only certain options are honored: @code{quiet},
774 @code{verbose}, @code{debug}, @code{debug-all}, @code{debug-level},
775 @code{debug-pinentry},
776 @code{no-grab}, @code{pinentry-program}, @code{default-cache-ttl},
777 @code{max-cache-ttl}, @code{ignore-cache-for-signing},
778 @code{no-allow-external-cache},
779 @code{no-allow-mark-trusted}, @code{disable-scdaemon}, and
780 @code{disable-check-own-socket}.  @code{scdaemon-program} is also
781 supported but due to the current implementation, which calls the
782 scdaemon only once, it is not of much use unless you manually kill the
783 scdaemon.
784
785
786 @item SIGTERM
787 @cpindex SIGTERM
788 Shuts down the process but waits until all current requests are
789 fulfilled.  If the process has received 3 of these signals and requests
790 are still pending, a shutdown is forced.
791
792 @item SIGINT
793 @cpindex SIGINT
794 Shuts down the process immediately.
795
796 @item SIGUSR1
797 @cpindex SIGUSR1
798 Dump internal information to the log file.
799
800 @item SIGUSR2
801 @cpindex SIGUSR2
802 This signal is used for internal purposes.
803
804 @end table
805
806 @c
807 @c  Examples
808 @c
809 @mansect examples
810 @node Agent Examples
811 @section Examples
812
813 @ifset gpgtwoone
814 It is important to set the GPG_TTY environment variable in
815 your login shell, for example in the @file{~/.bashrc} init script:
816
817 @cartouche
818 @example
819   export GPG_TTY=$(tty)
820 @end example
821 @end cartouche
822
823 If you enabled the Ssh Agent Support, you also need to tell ssh about
824 it by adding this to your init script:
825
826 @cartouche
827 @example
828 unset SSH_AGENT_PID
829 if [ "$@{gnupg_SSH_AUTH_SOCK_by:-0@}" -ne $$ ]; then
830   export SSH_AUTH_SOCK="$@{HOME@}/.gnupg/S.gpg-agent.ssh"
831 fi
832 @end example
833 @end cartouche
834 @end ifset
835
836 @ifclear gpgtwoone
837 The usual way to invoke @command{gpg-agent} is
838
839 @example
840 $ eval $(gpg-agent --daemon)
841 @end example
842
843 An alternative way is by replacing @command{ssh-agent} with
844 @command{gpg-agent}.  If for example @command{ssh-agent} is started as
845 part of the Xsession initialization, you may simply replace
846 @command{ssh-agent} by a script like:
847
848 @cartouche
849 @example
850 #!/bin/sh
851
852 exec /usr/local/bin/gpg-agent --enable-ssh-support --daemon \
853       --write-env-file $@{HOME@}/.gpg-agent-info "$@@"
854 @end example
855 @end cartouche
856
857 @noindent
858 and add something like (for Bourne shells)
859
860 @cartouche
861 @example
862   if [ -f "$@{HOME@}/.gpg-agent-info" ]; then
863     . "$@{HOME@}/.gpg-agent-info"
864     export GPG_AGENT_INFO
865     export SSH_AUTH_SOCK
866   fi
867 @end example
868 @end cartouche
869
870 @noindent
871 to your shell initialization file (e.g. @file{~/.bashrc}).
872 @end ifclear
873
874 @c
875 @c  Assuan Protocol
876 @c
877 @manpause
878 @node Agent Protocol
879 @section Agent's Assuan Protocol
880
881 Note: this section does only document the protocol, which is used by
882 GnuPG components; it does not deal with the ssh-agent protocol.
883
884 @ifset gpgtwoone
885 The @command{gpg-agent} daemon is started on demand by the GnuPG
886 components.
887 @end ifset
888 @ifclear gpgtwoone
889 The @command{gpg-agent} should be started by the login shell and set an
890 environment variable to tell clients about the socket to be used.
891 Clients should deny to access an agent with a socket name which does
892 not match its own configuration.  An application may choose to start
893 an instance of the gpg-agent if it does not figure that any has been
894 started; it should not do this if a gpg-agent is running but not
895 usable.  Because @command{gpg-agent} can only be used in background mode, no
896 special command line option is required to activate the use of the
897 protocol.
898 @end ifclear
899
900 To identify a key we use a thing called keygrip which is the SHA-1 hash
901 of an canonical encoded S-Expression of the public key as used in
902 Libgcrypt.  For the purpose of this interface the keygrip is given as a
903 hex string.  The advantage of using this and not the hash of a
904 certificate is that it will be possible to use the same keypair for
905 different protocols, thereby saving space on the token used to keep the
906 secret keys.
907
908 @ifset gpgtwoone
909 The @command{gpg-agent} may send status messages during a command or when
910 returning from a command to inform a client about the progress or result of an
911 operation.  For example, the @var{INQUIRE_MAXLEN} status message may be sent
912 during a server inquire to inform the client of the maximum usable length of
913 the inquired data (which should not be exceeded).
914 @end ifset
915
916 @menu
917 * Agent PKDECRYPT::       Decrypting a session key
918 * Agent PKSIGN::          Signing a Hash
919 * Agent GENKEY::          Generating a Key
920 * Agent IMPORT::          Importing a Secret Key
921 * Agent EXPORT::          Exporting a Secret Key
922 * Agent ISTRUSTED::       Importing a Root Certificate
923 * Agent GET_PASSPHRASE::  Ask for a passphrase
924 * Agent CLEAR_PASSPHRASE:: Expire a cached passphrase
925 @ifset gpgtwoone
926 * Agent PRESET_PASSPHRASE:: Set a passphrase for a keygrip
927 @end ifset
928 * Agent GET_CONFIRMATION:: Ask for confirmation
929 * Agent HAVEKEY::         Check whether a key is available
930 * Agent LEARN::           Register a smartcard
931 * Agent PASSWD::          Change a Passphrase
932 * Agent UPDATESTARTUPTTY:: Change the Standard Display
933 * Agent GETEVENTCOUNTER:: Get the Event Counters
934 * Agent GETINFO::         Return information about the process
935 * Agent OPTION::          Set options for the session
936 @end menu
937
938 @node Agent PKDECRYPT
939 @subsection Decrypting a session key
940
941 The client asks the server to decrypt a session key.  The encrypted
942 session key should have all information needed to select the
943 appropriate secret key or to delegate it to a smartcard.
944
945 @example
946   SETKEY <keyGrip>
947 @end example
948
949 Tell the server about the key to be used for decryption.  If this is
950 not used, @command{gpg-agent} may try to figure out the key by trying to
951 decrypt the message with each key available.
952
953 @example
954   PKDECRYPT
955 @end example
956
957 The agent checks whether this command is allowed and then does an
958 INQUIRY to get the ciphertext the client should then send the cipher
959 text.
960
961 @example
962     S: INQUIRE CIPHERTEXT
963     C: D (xxxxxx
964     C: D xxxx)
965     C: END
966 @end example
967
968 Please note that the server may send status info lines while reading the
969 data lines from the client.  The data send is a SPKI like S-Exp with
970 this structure:
971
972 @example
973      (enc-val
974        (<algo>
975          (<param_name1> <mpi>)
976            ...
977          (<param_namen> <mpi>)))
978 @end example
979
980 Where algo is a string with the name of the algorithm; see the libgcrypt
981 documentation for a list of valid algorithms.  The number and names of
982 the parameters depend on the algorithm.  The agent does return an error
983 if there is an inconsistency.
984
985 If the decryption was successful the decrypted data is returned by
986 means of "D" lines.
987
988 Here is an example session:
989 @cartouche
990 @smallexample
991    C: PKDECRYPT
992    S: INQUIRE CIPHERTEXT
993    C: D (enc-val elg (a 349324324)
994    C: D    (b 3F444677CA)))
995    C: END
996    S: # session key follows
997    S: S PADDING 0
998    S: D (value 1234567890ABCDEF0)
999    S: OK descryption successful
1000 @end smallexample
1001 @end cartouche
1002
1003 The “PADDING” status line is only send if gpg-agent can tell what kind
1004 of padding is used.  As of now only the value 0 is used to indicate
1005 that the padding has been removed.
1006
1007
1008 @node Agent PKSIGN
1009 @subsection Signing a Hash
1010
1011 The client ask the agent to sign a given hash value.  A default key
1012 will be chosen if no key has been set.  To set a key a client first
1013 uses:
1014
1015 @example
1016    SIGKEY <keyGrip>
1017 @end example
1018
1019 This can be used multiple times to create multiple signature, the list
1020 of keys is reset with the next PKSIGN command or a RESET.  The server
1021 test whether the key is a valid key to sign something and responds with
1022 okay.
1023
1024 @example
1025    SETHASH --hash=<name>|<algo> <hexstring>
1026 @end example
1027
1028 The client can use this command to tell the server about the data <hexstring>
1029 (which usually is a hash) to be signed. <algo> is the decimal encoded hash
1030 algorithm number as used by Libgcrypt.  Either <algo> or --hash=<name>
1031 must be given.  Valid names for <name> are:
1032
1033 @table @code
1034 @item sha1
1035 The SHA-1 hash algorithm
1036 @item sha256
1037 The SHA-256 hash algorithm
1038 @item rmd160
1039 The RIPE-MD160 hash algorithm
1040 @item md5
1041 The old and broken MD5 hash algorithm
1042 @item tls-md5sha1
1043 A combined hash algorithm as used by the TLS protocol.
1044 @end table
1045
1046 @noindent
1047 The actual signing is done using
1048
1049 @example
1050    PKSIGN <options>
1051 @end example
1052
1053 Options are not yet defined, but my later be used to choose among
1054 different algorithms.  The agent does then some checks, asks for the
1055 passphrase and as a result the server returns the signature as an SPKI
1056 like S-expression in "D" lines:
1057
1058 @example
1059      (sig-val
1060        (<algo>
1061          (<param_name1> <mpi>)
1062            ...
1063          (<param_namen> <mpi>)))
1064 @end example
1065
1066
1067 The operation is affected by the option
1068
1069 @example
1070    OPTION use-cache-for-signing=0|1
1071 @end example
1072
1073 The default of @code{1} uses the cache.  Setting this option to @code{0}
1074 will lead @command{gpg-agent} to ignore the passphrase cache.  Note, that there is
1075 also a global command line option for @command{gpg-agent} to globally disable the
1076 caching.
1077
1078
1079 Here is an example session:
1080 @cartouche
1081 @smallexample
1082    C: SIGKEY <keyGrip>
1083    S: OK key available
1084    C: SIGKEY <keyGrip>
1085    S: OK key available
1086    C: PKSIGN
1087    S: # I did ask the user whether he really wants to sign
1088    S: # I did ask the user for the passphrase
1089    S: INQUIRE HASHVAL
1090    C: D ABCDEF012345678901234
1091    C: END
1092    S: # signature follows
1093    S: D (sig-val rsa (s 45435453654612121212))
1094    S: OK
1095 @end smallexample
1096 @end cartouche
1097
1098 @node Agent GENKEY
1099 @subsection Generating a Key
1100
1101 This is used to create a new keypair and store the secret key inside the
1102 active PSE --- which is in most cases a Soft-PSE.  An not yet defined
1103 option allows to choose the storage location.  To get the secret key out
1104 of the PSE, a special export tool has to be used.
1105
1106 @example
1107 @ifset gpgtwoone
1108    GENKEY [--no-protection] [--preset] [<cache_nonce>]
1109 @end ifset
1110 @ifclear gpgtwoone
1111    GENKEY
1112 @end ifclear
1113 @end example
1114
1115 Invokes the key generation process and the server will then inquire
1116 on the generation parameters, like:
1117
1118 @example
1119    S: INQUIRE KEYPARM
1120    C: D (genkey (rsa (nbits  1024)))
1121    C: END
1122 @end example
1123
1124 The format of the key parameters which depends on the algorithm is of
1125 the form:
1126
1127 @example
1128     (genkey
1129       (algo
1130         (parameter_name_1 ....)
1131           ....
1132         (parameter_name_n ....)))
1133 @end example
1134
1135 If everything succeeds, the server returns the *public key* in a SPKI
1136 like S-Expression like this:
1137
1138 @example
1139      (public-key
1140        (rsa
1141          (n <mpi>)
1142          (e <mpi>)))
1143 @end example
1144
1145 Here is an example session:
1146 @cartouche
1147 @smallexample
1148    C: GENKEY
1149    S: INQUIRE KEYPARM
1150    C: D (genkey (rsa (nbits  1024)))
1151    C: END
1152    S: D (public-key
1153    S: D   (rsa (n 326487324683264) (e 10001)))
1154    S  OK key created
1155 @end smallexample
1156 @end cartouche
1157
1158 @ifset gpgtwoone
1159 The @option{--no-protection} option may be used to prevent prompting for a
1160 passphrase to protect the secret key while leaving the secret key unprotected.
1161 The @option{--preset} option may be used to add the passphrase to the cache
1162 using the default cache parameters.
1163
1164 The @option{--inq-passwd} option may be used to create the key with a
1165 supplied passphrase.  When used the agent does an inquiry with the
1166 keyword @code{NEWPASSWD} to retrieve that passphrase.  This option
1167 takes precedence over @option{--no-protection}; however if the client
1168 sends a empty (zero-length) passphrase, this is identical to
1169 @option{--no-protection}.
1170 @end ifset
1171
1172 @node Agent IMPORT
1173 @subsection Importing a Secret Key
1174
1175 This operation is not yet supported by GpgAgent.  Specialized tools
1176 are to be used for this.
1177
1178 There is no actual need because we can expect that secret keys
1179 created by a 3rd party are stored on a smartcard.  If we have
1180 generated the key ourself, we do not need to import it.
1181
1182 @node Agent EXPORT
1183 @subsection Export a Secret Key
1184
1185 Not implemented.
1186
1187 Should be done by an extra tool.
1188
1189 @node Agent ISTRUSTED
1190 @subsection Importing a Root Certificate
1191
1192 Actually we do not import a Root Cert but provide a way to validate
1193 any piece of data by storing its Hash along with a description and
1194 an identifier in the PSE.  Here is the interface description:
1195
1196 @example
1197     ISTRUSTED <fingerprint>
1198 @end example
1199
1200 Check whether the OpenPGP primary key or the X.509 certificate with the
1201 given fingerprint is an ultimately trusted key or a trusted Root CA
1202 certificate.  The fingerprint should be given as a hexstring (without
1203 any blanks or colons or whatever in between) and may be left padded with
1204 00 in case of an MD5 fingerprint.  GPGAgent will answer with:
1205
1206 @example
1207     OK
1208 @end example
1209
1210 The key is in the table of trusted keys.
1211
1212 @example
1213     ERR 304 (Not Trusted)
1214 @end example
1215
1216 The key is not in this table.
1217
1218 Gpg needs the entire list of trusted keys to maintain the web of
1219 trust; the following command is therefore quite helpful:
1220
1221 @example
1222     LISTTRUSTED
1223 @end example
1224
1225 GpgAgent returns a list of trusted keys line by line:
1226
1227 @example
1228     S: D 000000001234454556565656677878AF2F1ECCFF P
1229     S: D 340387563485634856435645634856438576457A P
1230     S: D FEDC6532453745367FD83474357495743757435D S
1231     S: OK
1232 @end example
1233
1234 The first item on a line is the hexified fingerprint where MD5
1235 fingerprints are @code{00} padded to the left and the second item is a
1236 flag to indicate the type of key (so that gpg is able to only take care
1237 of PGP keys).  P = OpenPGP, S = S/MIME.  A client should ignore the rest
1238 of the line, so that we can extend the format in the future.
1239
1240 Finally a client should be able to mark a key as trusted:
1241
1242 @example
1243    MARKTRUSTED @var{fingerprint} "P"|"S"
1244 @end example
1245
1246 The server will then pop up a window to ask the user whether she
1247 really trusts this key. For this it will probably ask for a text to
1248 be displayed like this:
1249
1250 @example
1251    S: INQUIRE TRUSTDESC
1252    C: D Do you trust the key with the fingerprint @@FPR@@
1253    C: D bla fasel blurb.
1254    C: END
1255    S: OK
1256 @end example
1257
1258 Known sequences with the pattern @@foo@@ are replaced according to this
1259 table:
1260
1261 @table @code
1262 @item @@FPR16@@
1263 Format the fingerprint according to gpg rules for a v3 keys.
1264 @item @@FPR20@@
1265 Format the fingerprint according to gpg rules for a v4 keys.
1266 @item @@FPR@@
1267 Choose an appropriate format to format the fingerprint.
1268 @item @@@@
1269 Replaced by a single @code{@@}
1270 @end table
1271
1272 @node Agent GET_PASSPHRASE
1273 @subsection Ask for a passphrase
1274
1275 This function is usually used to ask for a passphrase to be used for
1276 conventional encryption, but may also be used by programs which need
1277 special handling of passphrases.  This command uses a syntax which helps
1278 clients to use the agent with minimum effort.
1279
1280 @example
1281   GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]] \
1282                  [--qualitybar] @var{cache_id}                \
1283                  [@var{error_message} @var{prompt} @var{description}]
1284 @end example
1285
1286 @var{cache_id} is expected to be a string used to identify a cached
1287 passphrase.  Use a @code{X} to bypass the cache.  With no other
1288 arguments the agent returns a cached passphrase or an error.  By
1289 convention either the hexified fingerprint of the key shall be used for
1290 @var{cache_id} or an arbitrary string prefixed with the name of the
1291 calling application and a colon: Like @code{gpg:somestring}.
1292
1293 @var{error_message} is either a single @code{X} for no error message or
1294 a string to be shown as an error message like (e.g. "invalid
1295 passphrase").  Blanks must be percent escaped or replaced by @code{+}'.
1296
1297 @var{prompt} is either a single @code{X} for a default prompt or the
1298 text to be shown as the prompt.  Blanks must be percent escaped or
1299 replaced by @code{+}.
1300
1301 @var{description} is a text shown above the entry field.  Blanks must be
1302 percent escaped or replaced by @code{+}.
1303
1304 The agent either returns with an error or with a OK followed by the hex
1305 encoded passphrase.  Note that the length of the strings is implicitly
1306 limited by the maximum length of a command.  If the option
1307 @option{--data} is used, the passphrase is not returned on the OK line
1308 but by regular data lines; this is the preferred method.
1309
1310 If the option @option{--check} is used, the standard passphrase
1311 constraints checks are applied.  A check is not done if the passphrase
1312 has been found in the cache.
1313
1314 If the option @option{--no-ask} is used and the passphrase is not in the
1315 cache the user will not be asked to enter a passphrase but the error
1316 code @code{GPG_ERR_NO_DATA} is returned.
1317
1318 If the option @option{--qualitybar} is used and a minimum passphrase
1319 length has been configured, a visual indication of the entered
1320 passphrase quality is shown.
1321
1322 @example
1323   CLEAR_PASSPHRASE @var{cache_id}
1324 @end example
1325
1326 may be used to invalidate the cache entry for a passphrase.  The
1327 function returns with OK even when there is no cached passphrase.
1328
1329
1330
1331 @node Agent CLEAR_PASSPHRASE
1332 @subsection Remove a cached passphrase
1333
1334 Use this command to remove a cached passphrase.
1335
1336 @example
1337 @ifset gpgtwoone
1338   CLEAR_PASSPHRASE [--mode=normal] <cache_id>
1339 @end ifset
1340 @ifclear gpgtwoone
1341   CLEAR_PASSPHRASE <cache_id>
1342 @end ifclear
1343 @end example
1344
1345 @ifset gpgtwoone
1346 The @option{--mode=normal} option can be used to clear a @var{cache_id} that
1347 was set by gpg-agent.
1348 @end ifset
1349
1350
1351
1352 @ifset gpgtwoone
1353 @node Agent PRESET_PASSPHRASE
1354 @subsection Set a passphrase for a keygrip
1355
1356 This command adds a passphrase to the cache for the specified @var{keygrip}.
1357
1358 @example
1359   PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]
1360 @end example
1361
1362 The passphrase is a hexidecimal string when specified. When not specified, the
1363 passphrase will be retrieved from the pinentry module unless the
1364 @option{--inquire} option was specified in which case the passphrase will be
1365 retrieved from the client.
1366
1367 The @var{timeout} parameter keeps the passphrase cached for the specified
1368 number of seconds. A value of @code{-1} means infinate while @code{0} means
1369 the default (currently only a timeout of -1 is allowed, which means to never
1370 expire it).
1371 @end ifset
1372
1373
1374
1375
1376 @node Agent GET_CONFIRMATION
1377 @subsection Ask for confirmation
1378
1379 This command may be used to ask for a simple confirmation by
1380 presenting a text and 2 buttons: Okay and Cancel.
1381
1382 @example
1383   GET_CONFIRMATION @var{description}
1384 @end example
1385
1386 @var{description}is displayed along with a Okay and Cancel
1387 button. Blanks must be percent escaped or replaced by @code{+}.  A
1388 @code{X} may be used to display confirmation dialog with a default
1389 text.
1390
1391 The agent either returns with an error or with a OK.  Note, that the
1392 length of @var{description} is implicitly limited by the maximum
1393 length of a command.
1394
1395
1396
1397 @node Agent HAVEKEY
1398 @subsection Check whether a key is available
1399
1400 This can be used to see whether a secret key is available.  It does
1401 not return any information on whether the key is somehow protected.
1402
1403 @example
1404   HAVEKEY @var{keygrips}
1405 @end example
1406
1407 The agent answers either with OK or @code{No_Secret_Key} (208).  The
1408 caller may want to check for other error codes as well.  More than one
1409 keygrip may be given.  In this case the command returns success if at
1410 least one of the keygrips corresponds to an available secret key.
1411
1412
1413 @node Agent LEARN
1414 @subsection Register a smartcard
1415
1416 @example
1417   LEARN [--send]
1418 @end example
1419
1420 This command is used to register a smartcard.  With the --send
1421 option given the certificates are send back.
1422
1423
1424 @node Agent PASSWD
1425 @subsection Change a Passphrase
1426
1427 @example
1428 @ifset gpgtwoone
1429   PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] @var{keygrip}
1430 @end ifset
1431 @ifclear gpgtwoone
1432   PASSWD @var{keygrip}
1433 @end ifclear
1434 @end example
1435
1436 This command is used to interactively change the passphrase of the key
1437 identified by the hex string @var{keygrip}.
1438
1439 @ifset gpgtwoone
1440 The @option{--preset} option may be used to add the new passphrase to the
1441 cache using the default cache parameters.
1442 @end ifset
1443
1444
1445 @node Agent UPDATESTARTUPTTY
1446 @subsection Change the standard display
1447
1448 @example
1449   UPDATESTARTUPTTY
1450 @end example
1451
1452 Set the startup TTY and X-DISPLAY variables to the values of this
1453 session.  This command is useful to direct future pinentry invocations
1454 to another screen.  It is only required because there is no way in the
1455 ssh-agent protocol to convey this information.
1456
1457
1458 @node Agent GETEVENTCOUNTER
1459 @subsection Get the Event Counters
1460
1461 @example
1462   GETEVENTCOUNTER
1463 @end example
1464
1465 This function return one status line with the current values of the
1466 event counters.  The event counters are useful to avoid polling by
1467 delaying a poll until something has changed.  The values are decimal
1468 numbers in the range @code{0} to @code{UINT_MAX} and wrapping around to
1469 0.  The actual values should not be relied upon; they shall only be used
1470 to detect a change.
1471
1472 The currently defined counters are are:
1473 @table @code
1474 @item ANY
1475 Incremented with any change of any of the other counters.
1476 @item KEY
1477 Incremented for added or removed private keys.
1478 @item CARD
1479 Incremented for changes of the card readers stati.
1480 @end table
1481
1482 @node Agent GETINFO
1483 @subsection  Return information about the process
1484
1485 This is a multipurpose function to return a variety of information.
1486
1487 @example
1488 GETINFO @var{what}
1489 @end example
1490
1491 The value of @var{what} specifies the kind of information returned:
1492 @table @code
1493 @item version
1494 Return the version of the program.
1495 @item pid
1496 Return the process id of the process.
1497 @item socket_name
1498 Return the name of the socket used to connect the agent.
1499 @item ssh_socket_name
1500 Return the name of the socket used for SSH connections.  If SSH support
1501 has not been enabled the error @code{GPG_ERR_NO_DATA} will be returned.
1502 @end table
1503
1504 @node Agent OPTION
1505 @subsection Set options for the session
1506
1507 Here is a list of session options which are not yet described with
1508 other commands.  The general syntax for an Assuan option is:
1509
1510 @smallexample
1511 OPTION  @var{key}=@var{value}
1512 @end smallexample
1513
1514 @noindent
1515 Supported @var{key}s are:
1516
1517 @table @code
1518 @item agent-awareness
1519 This may be used to tell gpg-agent of which gpg-agent version the
1520 client is aware of.  gpg-agent uses this information to enable
1521 features which might break older clients.
1522
1523 @item putenv
1524 Change the session's environment to be used for the
1525 Pinentry.  Valid values are:
1526
1527   @table @code
1528   @item @var{name}
1529   Delete envvar @var{name}
1530   @item @var{name}=
1531   Set envvar @var{name} to the empty string
1532   @item @var{name}=@var{value}
1533   Set envvar @var{name} to the string @var{value}.
1534   @end table
1535
1536 @item use-cache-for-signing
1537 See Assuan command @code{PKSIGN}.
1538
1539 @item allow-pinentry-notify
1540 This does not need any value.  It is used to enable the
1541 PINENTRY_LAUNCHED inquiry.
1542
1543 @ifset gpgtwoone
1544 @item pinentry-mode
1545 This option is used to change the operation mode of the pinentry.  The
1546 following values are defined:
1547
1548   @table @code
1549   @item ask
1550   This is the default mode which pops up a pinentry as needed.
1551
1552   @item cancel
1553   Instead of popping up a pinentry, return the error code
1554   @code{GPG_ERR_CANCELED}.
1555
1556   @item error
1557   Instead of popping up a pinentry, return the error code
1558   @code{GPG_ERR_NO_PIN_ENTRY}.
1559
1560   @item loopback
1561   Use a loopback pinentry.  This fakes a pinentry by using inquiries
1562   back to the caller to ask for a passphrase.  This option may only be
1563   set if the agent has been configured for that.
1564   Use the @xref{option --allow-loopback-pinentry}.
1565
1566   @end table
1567 @end ifset
1568
1569 @ifset gpgtwoone
1570 @item cache-ttl-opt-preset
1571 This option sets the cache TTL for new entries created by GENKEY and
1572 PASSWD commands when using the @option{--preset} option.  It it is not
1573 used a default value is used.
1574 @end ifset
1575
1576 @ifset gpgtwoone
1577 @item s2k-count
1578 Instead of using the standard S2K count (which is computed on the
1579 fly), the given S2K count is used for new keys or when changing the
1580 passphrase of a key.  Values below 65536 are considered to be 0.  This
1581 option is valid for the entire session or until reset to 0.  This
1582 option is useful if the key is later used on boxes which are either
1583 much slower or faster than the actual box.
1584 @end ifset
1585
1586 @end table
1587
1588
1589 @mansect see also
1590 @ifset isman
1591 @command{gpg2}(1),
1592 @command{gpgsm}(1),
1593 @command{gpg-connect-agent}(1),
1594 @command{scdaemon}(1)
1595 @end ifset
1596 @include see-also-note.texi