1GPG-AGENT(1) GNU Privacy Guard GPG-AGENT(1)
2
3
4
6 gpg-agent - Secret key management for GnuPG
7
9 gpg-agent [--homedir dir] [--options file] [options]
10 gpg-agent [--homedir dir] [--options file] [options] --server
11 gpg-agent [--homedir dir] [--options file] [options] --daemon [com‐
12 mand_line]
13
14
16 gpg-agent is a daemon to manage secret (private) keys independently
17 from any protocol. It is used as a backend for gpg and gpgsm as well
18 as for a couple of other utilities.
19
20
21 The usual way to run the agent is from the ~/.xsession file:
22
23 eval $(gpg-agent --daemon)
24
25
26 If you don't use an X server, you can also put this into your regular
27 startup file ~/.profile or .bash_profile. It is best not to run multi‐
28 ple instance of the gpg-agent, so you should make sure that only one is
29 running: gpg-agent uses an environment variable to inform clients about
30 the communication parameters. You can write the content of this envi‐
31 ronment variable to a file so that you can test for a running agent.
32 Here is an example using Bourne shell syntax:
33
34 gpg-agent --daemon --enable-ssh-support \
35 --write-env-file "${HOME}/.gpg-agent-info"
36
37 This code should only be run once per user session to initially fire up
38 the agent. In the example the optional support for the included Secure
39 Shell agent is enabled and the information about the agent is written
40 to a file in the HOME directory. Note that by running gpg-agent with‐
41 out arguments you may test whether an agent is already running; however
42 such a test may lead to a race condition, thus it is not suggested.
43
44
45 The second script needs to be run for each interactive session:
46
47 if [ -f "${HOME}/.gpg-agent-info" ]; then
48 . "${HOME}/.gpg-agent-info"
49 export GPG_AGENT_INFO
50 export SSH_AUTH_SOCK
51 export SSH_AGENT_PID
52 fi
53
54
55 It reads the data out of the file and exports the variables. If you
56 don't use Secure Shell, you don't need the last two export statements.
57
58
59 You should always add the following lines to your .bashrc or whatever
60 initialization file is used for all shell invocations:
61
62 GPG_TTY=$(tty)
63 export GPG_TTY
64
65
66 It is important that this environment variable always reflects the out‐
67 put of the tty command. For W32 systems this option is not required.
68
69 Please make sure that a proper pinentry program has been installed
70 under the default filename (which is system dependant) or use the
71 option pinentry-program to specify the full name of that program. It
72 is often useful to install a symbolic link from the actual used pinen‐
73 try (e.g. ‘/usr/bin/pinentry-gtk’) to the expected one (e.g.
74 ‘/usr/bin/pinentry’).
75
76
77
78
80 Commands are not distinguished from options except for the fact that
81 only one command is allowed.
82
83
84 --version
85 Print the program version and licensing information. Not that
86 you can abbreviate this command.
87
88
89 --help
90
91 -h Print a usage message summarizing the most useful command-line
92 options. Not that you can abbreviate this command.
93
94
95 --dump-options
96 Print a list of all available options and commands. Not that
97 you can abbreviate this command.
98
99
100 --server
101 Run in server mode and wait for commands on the stdin. The
102 default mode is to create a socket and listen for commands
103 there.
104
105
106 --daemon [command line]
107 Start the gpg-agent as a daemon; that is, detach it from the
108 console and run it in the background. Because gpg-agent prints
109 out important information required for further use, a common way
110 of invoking gpg-agent is: eval $(gpg-agent --daemon) to setup
111 the environment variables. The option --write-env-file is
112 another way commonly used to do this. Yet another way is creat‐
113 ing a new process as a child of gpg-agent: gpg-agent --daemon
114 /bin/sh. This way you get a new shell with the environment set‐
115 up properly; if you exit from this shell, gpg-agent terminates
116 as well.
117
118
120 --options file
121 Reads configuration from file instead of from the default per-
122 user configuration file. The default configuration file is
123 named ‘gpg-agent.conf’ and expected in the ‘.gnupg’ directory
124 directly below the home directory of the user.
125
126
127
128 --homedir dir
129 Set the name of the home directory to dir. If this option is not
130 used, the home directory defaults to ‘~/.gnupg’. It is only
131 recognized when given on the command line. It also overrides
132 any home directory stated through the environment variable
133 ‘GNUPGHOME’ or (on W32 systems) by means of the Registry entry
134 HKCU\Software\GNU\GnuPG:HomeDir.
135
136
137
138
139 -v
140
141 --verbose
142 Outputs additional information while running. You can increase
143 the verbosity by giving several verbose commands to gpgsm, such
144 as '-vv'.
145
146
147 -q
148
149 --quiet
150 Try to be as quiet as possible.
151
152
153 --batch
154 Don't invoke a pinentry or do any other thing requiring human
155 interaction.
156
157
158 --faked-system-time epoch
159 This option is only useful for testing; it sets the system time
160 back or forth to epoch which is the number of seconds elapsed
161 since the year 1970.
162
163
164 --debug-level level
165 Select the debug level for investigating problems. level may be
166 a numeric value or a keyword:
167
168
169 none No debugging at all. A value of less than 1 may be used
170 instead of the keyword.
171
172 basic Some basic debug messages. A value between 1 and 2 may
173 be used instead of the keyword.
174
175 advanced
176 More verbose debug messages. A value between 3 and 5 may
177 be used instead of the keyword.
178
179 expert Even more detailed messages. A value between 6 and 8 may
180 be used instead of the keyword.
181
182 guru All of the debug messages you can get. A value greater
183 than 8 may be used instead of the keyword. The creation
184 of hash tracing files is only enabled if the keyword is
185 used.
186
187 How these messages are mapped to the actual debugging flags is not
188 specified and may change with newer releases of this program. They are
189 however carefully selected to best aid in debugging.
190
191
192 --debug flags
193 This option is only useful for debugging and the behaviour may
194 change at any time without notice. FLAGS are bit encoded and
195 may be given in usual C-Syntax. The currently defined bits are:
196
197
198 0 (1) X.509 or OpenPGP protocol related data
199
200 1 (2) values of big number integers
201
202 2 (4) low level crypto operations
203
204 5 (32) memory allocation
205
206 6 (64) caching
207
208 7 (128)
209 show memory statistics.
210
211 9 (512)
212 write hashed data to files named dbgmd-000*
213
214 10 (1024)
215 trace Assuan protocol
216
217 12 (4096)
218 bypass all certificate validation
219
220
221 --debug-all
222 Same as --debug=0xffffffff
223
224
225 --debug-wait n
226 When running in server mode, wait n seconds before entering the
227 actual processing loop and print the pid. This gives time to
228 attach a debugger.
229
230
231 --no-detach
232 Don't detach the process from the console. This is mainly use‐
233 ful for debugging.
234
235
236 -s
237
238 --sh
239
240 -c
241
242 --csh Format the info output in daemon mode for use with the standard
243 Bourne shell or the C-shell respectively. The default is to
244 guess it based on the environment variable SHELL which is cor‐
245 rect in almost all cases.
246
247
248 --write-env-file file
249 Often it is required to connect to the agent from a process not
250 being an inferior of gpg-agent and thus the environment variable
251 with the socket name is not available. To help setting up those
252 variables in other sessions, this option may be used to write
253 the information into file. If file is not specified the default
254 name ‘${HOME}/.gpg-agent-info’ will be used. The format is
255 suitable to be evaluated by a Bourne shell like in this simple
256 example:
257
258 eval $(cat file)
259 eval $(cut -d= -f 1 < file | xargs echo export)
260
261
262
263
264 --no-grab
265 Tell the pinentry not to grab the keyboard and mouse. This
266 option should in general not be used to avoid X-sniffing
267 attacks.
268
269
270 --log-file file
271 Append all logging output to file. This is very helpful in see‐
272 ing what the agent actually does.
273
274
275
276 --allow-mark-trusted
277 Allow clients to mark keys as trusted, i.e. put them into the
278 ‘trustlist.txt’ file. This is by default not allowed to make it
279 harder for users to inadvertently accept Root-CA keys.
280
281
282 --ignore-cache-for-signing
283 This option will let gpg-agent bypass the passphrase cache for
284 all signing operation. Note that there is also a per-session
285 option to control this behaviour but this command line option
286 takes precedence.
287
288
289 --default-cache-ttl n
290 Set the time a cache entry is valid to n seconds. The default
291 is 600 seconds.
292
293
294 --default-cache-ttl-ssh n
295 Set the time a cache entry used for SSH keys is valid to n sec‐
296 onds. The default is 1800 seconds.
297
298
299 --max-cache-ttl n
300 Set the maximum time a cache entry is valid to n seconds. After
301 this time a cache entry will be expired even if it has been
302 accessed recently. The default is 2 hours (7200 seconds).
303
304
305 --max-cache-ttl-ssh n
306 Set the maximum time a cache entry used for SSH keys is valid to
307 n seconds. After this time a cache entry will be expired even
308 if it has been accessed recently. The default is 2 hours (7200
309 seconds).
310
311
312 --enforce-passphrase-constraints
313 Enforce the passphrase constraints by not allowing the user to
314 bypass them using the ``Take it anyway'' button.
315
316
317 --min-passphrase-len n
318 Set the minimal length of a passphrase. When entering a new
319 passphrase shorter than this value a warning will be displayed.
320 Defaults to 8.
321
322
323 --min-passphrase-nonalpha n
324 Set the minimal number of digits or special characters required
325 in a passphrase. When entering a new passphrase with less than
326 this number of digits or special characters a warning will be
327 displayed. Defaults to 1.
328
329
330 --check-passphrase-pattern file
331 Check the passphrase against the pattern given in file. When
332 entering a new passphrase matching one of these pattern a warn‐
333 ing will be displayed. file should be an absolute filename. The
334 default is not to use any pattern file.
335
336 Security note: It is known that checking a passphrase against a
337 list of pattern or even against a complete dictionary is not
338 very effective to enforce good passphrases. Users will soon
339 figure up ways to bypass such a policy. A better policy is to
340 educate users on good security behavior and optionally to run a
341 passphrase cracker regularly on all users passphrases to catch
342 the very simple ones.
343
344
345 --max-passphrase-days n
346 Ask the user to change the passphrase if n days have passed
347 since the last change. With --enforce-passphrase-constraints
348 set the user may not bypass this check.
349
350
351 --enable-passphrase-history
352 This option does nothing yet.
353
354
355 --pinentry-program filename
356 Use program filename as the PIN entry. The default is installa‐
357 tion dependent and can be shown with the --version command.
358
359
360 --pinentry-touch-file filename
361 By default the filename of the socket gpg-agent is listening for
362 requests is passed to Pinentry, so that it can touch that file
363 before exiting (it does this only in curses mode). This option
364 changes the file passed to Pinentry to filename. The special
365 name /dev/null may be used to completely disable this feature.
366 Note that Pinentry will not create that file, it will only
367 change the modification and access time.
368
369
370
371 --scdaemon-program filename
372 Use program filename as the Smartcard daemon. The default is
373 installation dependent and can be shown with the --version com‐
374 mand.
375
376
377 --disable-scdaemon
378 Do not make use of the scdaemon tool. This option has the
379 effect of disabling the ability to do smartcard operations.
380 Note, that enabling this option at runtime does not kill an
381 already forked scdaemon.
382
383
384 --use-standard-socket
385
386 --no-use-standard-socket
387 By enabling this option gpg-agent will listen on the socket
388 named ‘S.gpg-agent’, located in the home directory, and not cre‐
389 ate a random socket below a temporary directory. Tools connect‐
390 ing to gpg-agent should first try to connect to the socket given
391 in environment variable GPG_AGENT_INFO and then fall back to
392 this socket. This option may not be used if the home directory
393 is mounted as a remote file system. Note, that --use-standard-
394 socket is the default on Windows systems.
395
396
397
398 --display string
399
400 --ttyname string
401
402 --ttytype string
403
404 --lc-ctype string
405
406 --lc-messages string
407
408 --xauthority string
409 These options are used with the server mode to pass localization
410 information.
411
412
413 --keep-tty
414
415 --keep-display
416 Ignore requests to change the current tty or X window system's
417 DISPLAY variable respectively. This is useful to lock the
418 pinentry to pop up at the tty or display you started the agent.
419
420
421
422 --enable-ssh-support
423
424 Enable emulation of the OpenSSH Agent protocol.
425
426 In this mode of operation, the agent does not only implement the
427 gpg-agent protocol, but also the agent protocol used by OpenSSH
428 (through a separate socket). Consequently, it should be possi‐
429 ble to use the gpg-agent as a drop-in replacement for the well
430 known ssh-agent.
431
432 SSH Keys, which are to be used through the agent, need to be
433 added to the gpg-agent initially through the ssh-add utility.
434 When a key is added, ssh-add will ask for the password of the
435 provided key file and send the unprotected key material to the
436 agent; this causes the gpg-agent to ask for a passphrase, which
437 is to be used for encrypting the newly received key and storing
438 it in a gpg-agent specific directory.
439
440 Once a key has been added to the gpg-agent this way, the gpg-
441 agent will be ready to use the key.
442
443 Note: in case the gpg-agent receives a signature request, the
444 user might need to be prompted for a passphrase, which is neces‐
445 sary for decrypting the stored key. Since the ssh-agent proto‐
446 col does not contain a mechanism for telling the agent on which
447 display/terminal it is running, gpg-agent's ssh-support will use
448 the TTY or X display where gpg-agent has been started. To
449 switch this display to the current one, the following command
450 may be used:
451
452 echo UPDATESTARTUPTTY | gpg-connect-agent
453
454
455
456
457 All the long options may also be given in the configuration file after
458 stripping off the two leading dashes.
459
460
461
463 The usual way to invoke gpg-agent is
464
465 $ eval $(gpg-agent --daemon)
466
467 An alternative way is by replacing ssh-agent with gpg-agent. If for
468 example ssh-agent is started as part of the Xsession initialization,
469 you may simply replace ssh-agent by a script like:
470
471 #!/bin/sh
472
473 exec /usr/local/bin/gpg-agent --enable-ssh-support --daemon \
474 --write-env-file ${HOME}/.gpg-agent-info "$@"
475
476
477 and add something like (for Bourne shells)
478
479 if [ -f "${HOME}/.gpg-agent-info" ]; then
480 . "${HOME}/.gpg-agent-info"
481 export GPG_AGENT_INFO
482 export SSH_AUTH_SOCK
483 export SSH_AGENT_PID
484 fi
485
486
487 to your shell initialization file (e.g. ‘~/.bashrc’).
488
489
490
492 There are a few configuration files needed for the operation of the
493 agent. By default they may all be found in the current home directory
494 (see: [option --homedir]).
495
496
497
498 gpg-agent.conf
499 This is the standard configuration file read by gpg-agent on
500 startup. It may contain any valid long option; the leading
501 two dashes may not be entered and the option may not be abbre‐
502 viated.
503 This file is also read after a SIGHUP however only a few
504 options will actually have an effect. This default name may
505 be
506 changed on the command line (see: [option --options]).
507 You should backup this file.
508
509
510 trustlist.txt
511 This is the list of trusted keys. You should backup this
512 file.
513
514 Comment lines, indicated by a leading hash mark, as well as
515 empty
516 lines are ignored. To mark a key as trusted you need to enter
517 its
518 fingerprint followed by a space and a capital letter S.
519 Colons
520 may optionally be used to separate the bytes of a fingerprint;
521 this
522 allows to cut and paste the fingerprint from a key listing
523 output. If
524 the line is prefixed with a ! the key is explicitly marked as
525 not trusted.
526
527 Here is an example where two keys are marked as ultimately
528 trusted
529 and one as not trusted:
530
531 .RS 2
532 # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
533 A6935DD34EF3087973C706FC311AA2CCF733765B S
534
535 # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
536 DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
537
538 # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
539 !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
540 .fi
541
542 Before entering a key into this file, you need to ensure its
543 authenticity. How to do this depends on your organisation; your
544 administrator might have already entered those keys which are deemed
545 trustworthy enough into this file. Places where to look for the
546 fingerprint of a root certificate are letters received from the CA or
547 the website of the CA (after making 100% sure that this is indeed the
548 website of that CA). You may want to consider allowing interactive
549 updates of this file by using the see: [option --allow-mark-trusted].
550 This is however not as secure as maintaining this file manually. It is
551 even advisable to change the permissions to read-only so that this file
552 can't be changed inadvertently.
553
554 As a special feature a line include-default will include a global
555 list of trusted certificates (e.g. ‘/etc/gnupg/trustlist.txt’).
556 This global list is also used if the local list is not available.
557
558 It is possible to add further flags after the S for use by the
559 caller:
560
561
562 relax Relax checking of some root certificate requirements. This is for
563 example required if the certificate is missing the basicConstraints
564 attribute (despite that it is a MUST for CA certificates).
565
566
567 cm If validation of a certificate finally issued by a CA with this flag set
568 fails, try again using the chain validation model.
569
570
571
572
573 sshcontrol
574
575 This file is used when support for the secure shell agent protocol has
576 been enabled (see: [option --enable-ssh-support]). Only keys present in
577 this file are used in the SSH protocol. You should backup this file.
578
579 The ssh-add tool may be used to add new entries to this file;
580 you may also add them manually. Comment lines, indicated by a leading
581 hash mark, as well as empty lines are ignored. An entry starts with
582 optional whitespace, followed by the keygrip of the key given as 40 hex
583 digits, optionally followed by the caching TTL in seconds and another
584 optional field for arbitrary flags. A non-zero TTL overrides the global
585 default as set by --default-cache-ttl-ssh.
586
587 The keygrip may be prefixed with a ! to disable an entry entry.
588
589 The following example lists exactly one key. Note that keys available
590 through a OpenPGP smartcard in the active smartcard reader are
591 implicitly added to this list; i.e. there is no need to list them.
592
593 .RS 2
594 # Key added on 2005-02-25 15:08:29
595 5A6592BF45DC73BD876874A28FD4639282E29B52 0
596 .fi
597
598
599 private-keys-v1.d/
600
601 This is the directory where gpg-agent stores the private keys. Each
602 key is stored in a file with the name made up of the keygrip and the
603 suffix ‘key’. You should backup all files in this directory
604 and take great care to keep this backup closed away.
605
606
607
608 Note that on larger installations, it is useful to put predefined
609 files into the directory ‘/etc/skel/.gnupg/’ so that newly created
610 users start up with a working configuration. For existing users the
611 a small helper script is provided to create these files (see: [addgnupghome]).
612
613
614
615
616
618 A running gpg-agent may be controlled by signals, i.e. using the kill
619 command to send a signal to the process.
620
621 Here is a list of supported signals:
622
623
624
625 SIGHUP This signal flushes all cached passphrases and if the program
626 has been started with a configuration file, the configuration
627 file is read again. Only certain options are honored: quiet,
628 verbose, debug, debug-all, debug-level, no-grab, pinentry-pro‐
629 gram, default-cache-ttl, max-cache-ttl, ignore-cache-for-sign‐
630 ing, allow-mark-trusted and disable-scdaemon. scdaemon-program
631 is also supported but due to the current implementation, which
632 calls the scdaemon only once, it is not of much use unless you
633 manually kill the scdaemon.
634
635
636
637 SIGTERM
638 Shuts down the process but waits until all current requests are
639 fulfilled. If the process has received 3 of these signals and
640 requests are still pending, a shutdown is forced.
641
642
643 SIGINT Shuts down the process immediately.
644
645
646 SIGUSR1
647 Dump internal information to the log file.
648
649
650 SIGUSR2
651 This signal is used for internal purposes.
652
653
654
655
657 gpg2(1), gpgsm(1), gpg-connect-agent(1), scdaemon(1)
658
659 The full documentation for this tool is maintained as a Texinfo manual.
660 If GnuPG and the info program are properly installed at your site, the
661 command
662
663 info gnupg
664
665 should give you access to the complete manual including a menu struc‐
666 ture and an index.
667
668
669
670GnuPG 2.0.14 2018-07-13 GPG-AGENT(1)