1GPG-AGENT(1)                   GNU Privacy Guard                  GPG-AGENT(1)
2
3
4

NAME

6       gpg-agent - Secret key management for GnuPG
7

SYNOPSIS

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

DESCRIPTION

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       The agent is usualy started on demand by gpg, gpgsm,  gpgconf  or  gpg-
21       connect-agent.   Thus there is no reason to start it manually.  In case
22       you want to use the included Secure Shell Agent you may start the agent
23       using:
24
25         gpg-connect-agent /bye
26
27
28       The usual way to run the agent is from the ~/.xsession file:
29
30         eval $(gpg-agent --daemon)
31
32       If  you  don't use an X server, you can also put this into your regular
33       startup file ~/.profile or .bash_profile.  It is best not to run multi‐
34       ple instance of the gpg-agent, so you should make sure that only one is
35       running: gpg-agent uses an environment variable to inform clients about
36       the  communication  parameters. You can write the content of this envi‐
37       ronment variable to a file so that you can test for  a  running  agent.
38       Here is an example using Bourne shell syntax:
39
40         gpg-agent --daemon --enable-ssh-support \
41                   --write-env-file "${HOME}/.gpg-agent-info"
42
43       This code should only be run once per user session to initially fire up
44       the agent.  In the example the optional support for the included Secure
45       Shell  agent  is enabled and the information about the agent is written
46       to a file in the HOME directory.  Note that by running gpg-agent  with‐
47       out arguments you may test whether an agent is already running; however
48       such a test may lead to a race condition, thus it is not suggested.
49
50
51       The second script needs to be run for each interactive session:
52
53         if [ -f "${HOME}/.gpg-agent-info" ]; then
54           . "${HOME}/.gpg-agent-info"
55           export GPG_AGENT_INFO
56           export SSH_AUTH_SOCK
57         fi
58
59
60       It reads the data out of the file and exports the  variables.   If  you
61       don't use Secure Shell, you don't need the last two export statements.
62
63
64       You  should  always add the following lines to your .bashrc or whatever
65       initialization file is used for all shell invocations:
66
67         GPG_TTY=$(tty)
68         export GPG_TTY
69
70
71       It is important that this environment variable always reflects the out‐
72       put of the tty command.  For W32 systems this option is not required.
73
74       Please  make  sure  that  a  proper pinentry program has been installed
75       under the default filename (which  is  system  dependant)  or  use  the
76       option  pinentry-program  to specify the full name of that program.  It
77       is often useful to install a symbolic link from the actual used  pinen‐
78       try   (e.g.   ‘/usr/bin/pinentry-gtk’)   to   the  expected  one  (e.g.
79/usr/bin/pinentry’).
80
81
82
83

COMMANDS

85       Commands are not distinguished from options except for  the  fact  that
86       only one command is allowed.
87
88
89       --version
90              Print  the program version and licensing information.  Note that
91              you cannot abbreviate this command.
92
93
94       --help
95
96       -h     Print a usage message summarizing the most  useful  command-line
97              options.  Note that you cannot abbreviate this command.
98
99
100       --dump-options
101              Print  a  list of all available options and commands.  Note that
102              you cannot abbreviate this command.
103
104
105       --server
106              Run in server mode and wait for  commands  on  the  stdin.   The
107              default  mode  is  to  create  a  socket and listen for commands
108              there.
109
110
111       --daemon [command line]
112              Start the gpg-agent as a daemon; that is,  detach  it  from  the
113              console  and run it in the background.  Because gpg-agent prints
114              out important information required for further use, a common way
115              of  invoking  gpg-agent  is: eval $(gpg-agent --daemon) to setup
116              the  environment  variables.   The  option  --write-env-file  is
117              another way commonly used to do this.  Yet another way is creat‐
118              ing a new process as a child of  gpg-agent:  gpg-agent  --daemon
119              /bin/sh.  This way you get a new shell with the environment set‐
120              up properly; if you exit from this shell,  gpg-agent  terminates
121              as well.
122
123

OPTIONS

125       --options file
126              Reads  configuration  from file instead of from the default per-
127              user configuration file.   The  default  configuration  file  is
128              named  ‘gpg-agent.conf’  and  expected in the ‘.gnupg’ directory
129              directly below the home directory of the user.
130
131
132
133       --homedir dir
134              Set the name of the home directory to dir. If this option is not
135              used,  the  home  directory  defaults to ‘~/.gnupg’.  It is only
136              recognized when given on the command line.   It  also  overrides
137              any  home  directory  stated  through  the  environment variable
138GNUPGHOME’ or (on W32 systems) by means of the  Registry  entry
139              HKCU\Software\GNU\GnuPG:HomeDir.
140
141
142
143
144       -v
145
146       --verbose
147              Outputs  additional information while running.  You can increase
148              the verbosity by giving several verbose commands to gpgsm,  such
149              as '-vv'.
150
151
152       -q
153
154       --quiet
155              Try to be as quiet as possible.
156
157
158       --batch
159              Don't  invoke  a  pinentry or do any other thing requiring human
160              interaction.
161
162
163       --faked-system-time epoch
164              This option is only useful for testing; it sets the system  time
165              back  or  forth  to epoch which is the number of seconds elapsed
166              since the year 1970.
167
168
169       --debug-level level
170              Select the debug level for investigating problems. level may  be
171              a numeric value or a keyword:
172
173
174              none   No  debugging at all.  A value of less than 1 may be used
175                     instead of the keyword.
176
177              basic  Some basic debug messages.  A value between 1 and  2  may
178                     be used instead of the keyword.
179
180              advanced
181                     More verbose debug messages.  A value between 3 and 5 may
182                     be used instead of the keyword.
183
184              expert Even more detailed messages.  A value between 6 and 8 may
185                     be used instead of the keyword.
186
187              guru   All  of  the  debug messages you can get. A value greater
188                     than 8 may be used instead of the keyword.  The  creation
189                     of  hash  tracing files is only enabled if the keyword is
190                     used.
191
192       How these messages are mapped to the  actual  debugging  flags  is  not
193       specified  and may change with newer releases of this program. They are
194       however carefully selected to best aid in debugging.
195
196
197       --debug flags
198              This option is only useful for debugging and the  behaviour  may
199              change  at  any  time without notice.  FLAGS are bit encoded and
200              may be given in usual C-Syntax. The currently defined bits are:
201
202
203              0 (1)  X.509 or OpenPGP protocol related data
204
205              1 (2)  values of big number integers
206
207              2 (4)  low level crypto operations
208
209              5 (32) memory allocation
210
211              6 (64) caching
212
213              7 (128)
214                     show memory statistics.
215
216              9 (512)
217                     write hashed data to files named dbgmd-000*
218
219              10 (1024)
220                     trace Assuan protocol
221
222              12 (4096)
223                     bypass all certificate validation
224
225
226       --debug-all
227              Same as --debug=0xffffffff
228
229
230       --debug-wait n
231              When running in server mode, wait n seconds before entering  the
232              actual  processing  loop  and print the pid.  This gives time to
233              attach a debugger.
234
235
236       --no-detach
237              Don't detach the process from the console.  This is mainly  use‐
238              ful for debugging.
239
240
241       -s
242
243       --sh
244
245       -c
246
247       --csh  Format  the info output in daemon mode for use with the standard
248              Bourne shell or the C-shell respectively.   The  default  is  to
249              guess  it  based on the environment variable SHELL which is cor‐
250              rect in almost all cases.
251
252
253       --write-env-file file
254              Often it is required to connect to the agent from a process  not
255              being an inferior of gpg-agent and thus the environment variable
256              with the socket name is not available.  To help setting up those
257              variables  in  other  sessions, this option may be used to write
258              the information into file.  If file is not specified the default
259              name  ‘${HOME}/.gpg-agent-info’  will  be  used.   The format is
260              suitable to be evaluated by a Bourne shell like in  this  simple
261              example:
262
263         eval $(cat file)
264         eval $(cut -d= -f 1 < file | xargs echo export)
265
266
267
268
269       --no-grab
270              Tell  the  pinentry  not  to  grab the keyboard and mouse.  This
271              option should  in  general  not  be  used  to  avoid  X-sniffing
272              attacks.
273
274
275
276       --log-file file
277              Append all logging output to file.  This is very helpful in see‐
278              ing what the agent actually does.  If neither a log file  nor  a
279              log file descriptor has been set on a Windows platform, the Reg‐
280              istry entry HKCU\Software\GNU\GnuPG:DefaultLogFile, if  set,  is
281              used to specify the logging output.
282
283
284
285
286       --allow-mark-trusted
287              Allow  clients  to  mark keys as trusted, i.e. put them into the
288trustlist.txt’ file.  This is by default not allowed to make it
289              harder for users to inadvertently accept Root-CA keys.
290
291
292
293       --allow-loopback-pinentry
294              Allow  clients  to  use  the loopback pinentry features; see the
295              option pinentry-mode for details.
296
297
298       --ignore-cache-for-signing
299              This option will let gpg-agent bypass the passphrase  cache  for
300              all  signing  operation.   Note that there is also a per-session
301              option to control this behaviour but this  command  line  option
302              takes precedence.
303
304
305       --default-cache-ttl n
306              Set  the  time a cache entry is valid to n seconds.  The default
307              is 600 seconds.
308
309
310       --default-cache-ttl-ssh n
311              Set the time a cache entry used for SSH keys is valid to n  sec‐
312              onds.  The default is 1800 seconds.
313
314
315       --max-cache-ttl n
316              Set the maximum time a cache entry is valid to n seconds.  After
317              this time a cache entry will be expired  even  if  it  has  been
318              accessed recently.  The default is 2 hours (7200 seconds).
319
320
321       --max-cache-ttl-ssh n
322              Set the maximum time a cache entry used for SSH keys is valid to
323              n seconds.  After this time a cache entry will be  expired  even
324              if  it has been accessed recently.  The default is 2 hours (7200
325              seconds).
326
327
328       --enforce-passphrase-constraints
329              Enforce the passphrase constraints by not allowing the  user  to
330              bypass them using the ``Take it anyway'' button.
331
332
333       --min-passphrase-len n
334              Set  the  minimal  length  of a passphrase.  When entering a new
335              passphrase shorter than this value a warning will be  displayed.
336              Defaults to 8.
337
338
339       --min-passphrase-nonalpha n
340              Set  the minimal number of digits or special characters required
341              in a passphrase.  When entering a new passphrase with less  than
342              this  number  of  digits or special characters a warning will be
343              displayed.  Defaults to 1.
344
345
346       --check-passphrase-pattern file
347              Check the passphrase against the pattern given  in  file.   When
348              entering  a new passphrase matching one of these pattern a warn‐
349              ing will be displayed. file should be an absolute filename.  The
350              default is not to use any pattern file.
351
352              Security  note: It is known that checking a passphrase against a
353              list of pattern or even against a  complete  dictionary  is  not
354              very  effective  to  enforce  good passphrases.  Users will soon
355              figure up ways to bypass such a policy.  A better policy  is  to
356              educate  users on good security behavior and optionally to run a
357              passphrase cracker regularly on all users passphrases  to  catch
358              the very simple ones.
359
360
361       --max-passphrase-days n
362              Ask  the  user  to  change  the passphrase if n days have passed
363              since the last  change.   With  --enforce-passphrase-constraints
364              set the user may not bypass this check.
365
366
367       --enable-passphrase-history
368              This option does nothing yet.
369
370
371       --pinentry-program filename
372              Use program filename as the PIN entry.  The default is installa‐
373              tion dependent.
374
375
376       --pinentry-touch-file filename
377              By default the filename of the socket gpg-agent is listening for
378              requests  is  passed to Pinentry, so that it can touch that file
379              before exiting (it does this only in curses mode).  This  option
380              changes  the  file  passed to Pinentry to filename.  The special
381              name /dev/null may be used to completely disable  this  feature.
382              Note  that  Pinentry  will  not  create  that file, it will only
383              change the modification and access time.
384
385
386
387       --scdaemon-program filename
388              Use program filename as the Smartcard daemon.   The  default  is
389              installation  dependent  and  can be shown with the gpgconf com‐
390              mand.
391
392
393       --disable-scdaemon
394              Do not make use of the  scdaemon  tool.   This  option  has  the
395              effect  of  disabling  the  ability  to do smartcard operations.
396              Note, that enabling this option at  runtime  does  not  kill  an
397              already forked scdaemon.
398
399
400       --use-standard-socket
401
402       --no-use-standard-socket
403              By  enabling  this  option  gpg-agent  will listen on the socket
404              named ‘S.gpg-agent’, located in the home directory, and not cre‐
405              ate a random socket below a temporary directory.  Tools connect‐
406              ing to gpg-agent should first try to connect to the socket given
407              in  environment  variable  GPG_AGENT_INFO  and then fall back to
408              this socket.  This option may not be used if the home  directory
409              is  mounted  on a remote file system which does not support spe‐
410              cial files like fifos or sockets.   Note,  that  --use-standard-
411              socket  is  the  default  on all systems since GnuPG 2.1.  Note,
412              that --use-standard-socket is the default  on  Windows  systems.
413              The  default  may  be  changed at build time.  It is possible to
414              test at runtime whether the agent has been  configured  for  use
415              with the standard socket by issuing the command gpg-agent --use-
416              standard-socket-p which returns success if the  standard  socket
417              option has been enabled.
418
419
420       --display string
421
422       --ttyname string
423
424       --ttytype string
425
426       --lc-ctype string
427
428       --lc-messages string
429
430       --xauthority string
431              These options are used with the server mode to pass localization
432              information.
433
434
435       --keep-tty
436
437       --keep-display
438              Ignore requests to change the current tty or X  window  system's
439              DISPLAY  variable  respectively.   This  is  useful  to lock the
440              pinentry to pop up at the tty or display you started the agent.
441
442
443
444       --enable-ssh-support
445
446              Enable the OpenSSH Agent protocol.
447
448              In this mode of operation, the agent does not only implement the
449              gpg-agent  protocol, but also the agent protocol used by OpenSSH
450              (through a separate socket).  Consequently, it should be  possi‐
451              ble  to  use the gpg-agent as a drop-in replacement for the well
452              known ssh-agent.
453
454              SSH Keys, which are to be used through the  agent,  need  to  be
455              added  to  the  gpg-agent initially through the ssh-add utility.
456              When a key is added, ssh-add will ask for the  password  of  the
457              provided  key  file and send the unprotected key material to the
458              agent; this causes the gpg-agent to ask for a passphrase,  which
459              is  to be used for encrypting the newly received key and storing
460              it in a gpg-agent specific directory.
461
462              Once a key has been added to the gpg-agent this  way,  the  gpg-
463              agent will be ready to use the key.
464
465              Note:  in  case  the gpg-agent receives a signature request, the
466              user might need to be prompted for a passphrase, which is neces‐
467              sary  for decrypting the stored key.  Since the ssh-agent proto‐
468              col does not contain a mechanism for telling the agent on  which
469              display/terminal it is running, gpg-agent's ssh-support will use
470              the TTY or X display  where  gpg-agent  has  been  started.   To
471              switch  this  display  to the current one, the following command
472              may be used:
473
474         gpg-connect-agent updatestartuptty /bye
475
476       Although all GnuPG components try to start  the  gpg-agent  as  needed,
477       this  is  not  possible  for  the ssh support because ssh does not know
478       about it.  Thus if no GnuPG tool which accesses the agent has been run,
479       there  is no guarantee that ssh is abale to use gpg-agent for authenti‐
480       cation.  To fix this you may start gpg-agent if needed using this  sim‐
481       ple command:
482
483         gpg-connect-agent /bye
484
485       Adding the --verbose shows the progress of starting the agent.
486
487
488       All  the long options may also be given in the configuration file after
489       stripping off the two leading dashes.
490
491
492

EXAMPLES

494       The usual way to invoke gpg-agent is
495
496         $ eval $(gpg-agent --daemon)
497
498       An alternative way is by replacing ssh-agent with  gpg-agent.   If  for
499       example  ssh-agent  is  started as part of the Xsession initialization,
500       you may simply replace ssh-agent by a script like:
501
502         #!/bin/sh
503
504         exec /usr/local/bin/gpg-agent --enable-ssh-support --daemon \
505               --write-env-file ${HOME}/.gpg-agent-info "$@"
506
507
508       and add something like (for Bourne shells)
509
510           if [ -f "${HOME}/.gpg-agent-info" ]; then
511             . "${HOME}/.gpg-agent-info"
512             export GPG_AGENT_INFO
513             export SSH_AUTH_SOCK
514           fi
515
516
517       to your shell initialization file (e.g. ‘~/.bashrc’).
518
519
520

FILES

522       There are a few configuration files needed for  the  operation  of  the
523       agent.  By  default they may all be found in the current home directory
524       (see: [option --homedir]).
525
526
527
528       gpg-agent.conf
529                This is the standard configuration file read by gpg-agent on
530                startup.  It may contain any valid long option; the leading
531                two dashes may not be entered and the option may not be abbre‐
532              viated.
533                This file is also read after a SIGHUP however only a few
534                options  will  actually have an effect.  This default name may
535              be
536                changed on the command line (see: [option --options]).
537                You should backup this file.
538
539
540       trustlist.txt
541                This is the list of trusted  keys.   You  should  backup  this
542              file.
543
544                Comment  lines,  indicated  by a leading hash mark, as well as
545              empty
546                lines are ignored.  To mark a key as trusted you need to enter
547              its
548                fingerprint  followed  by  a  space  and  a  capital letter S.
549              Colons
550                may optionally be used to separate the bytes of a fingerprint;
551              this
552                allows  to  cut  and  paste the fingerprint from a key listing
553              output.  If
554                the line is prefixed with a ! the key is explicitly marked as
555                not trusted.
556
557                Here is an example where two keys  are  marked  as  ultimately
558              trusted
559                and one as not trusted:
560
561                .RS 2
562                # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
563                A6935DD34EF3087973C706FC311AA2CCF733765B S
564
565                # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
566                DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
567
568                # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
569                !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
570                .fi
571
572       Before entering a key into this file, you need to ensure its
573       authenticity.  How to do this depends on your organisation; your
574       administrator might have already entered those keys which are deemed
575       trustworthy enough into this file.  Places where to look for the
576       fingerprint of a root certificate are letters received from the CA or
577       the website of the CA (after making 100% sure that this is indeed the
578       website of that CA).  You may want to consider allowing interactive
579       updates of this file by using the see: [option --allow-mark-trusted].
580       This is however not as secure as maintaining this file manually.  It is
581       even advisable to change the permissions to read-only so that this file
582       can't be changed inadvertently.
583
584       As a special feature a line include-default will include a global
585       list of trusted certificates (e.g. ‘/etc/gnupg/trustlist.txt’).
586       This global list is also used if the local list is not available.
587
588       It is possible to add further flags after the S for use by the
589       caller:
590
591
592
593              relax  Relax checking of some root certificate requirements.  As of now this
594                     flag allows the use of root certificates with a missing basicConstraints
595                     attribute (despite that it is a MUST for CA certificates) and disables
596                     CRL checking for the root certificate.
597
598
599              cm     If validation of a certificate finally issued by a CA with this flag set
600                     fails, try again using the chain validation model.
601
602
603
604
605       sshcontrol
606              This file is used when support for the secure shell agent protocol has
607              been enabled (see: [option --enable-ssh-support]). Only keys present in
608              this file are used in the SSH protocol.  You should backup this file.
609
610              The ssh-add tool may be used to add new entries to this file;
611              you may also add them manually.  Comment lines, indicated by a leading
612              hash mark, as well as empty lines are ignored.  An entry starts with
613              optional whitespace, followed by the keygrip of the key given as 40 hex
614              digits, optionally followed by the caching TTL in seconds and another
615              optional field for arbitrary flags.  A non-zero TTL overrides the global
616              default as set by --default-cache-ttl-ssh.
617
618              The only flag support is confirm.  If this flag is found for a
619              key, each use of the key will pop up a pinentry to confirm the use of
620              that key.  The flag is automatically set if a new key was loaded into
621              gpg-agent using the option -c of the ssh-add
622              command.
623
624              The keygrip may be prefixed with a ! to disable an entry entry.
625
626              The following example lists exactly one key.  Note that keys available
627              through a OpenPGP smartcard in the active smartcard reader are
628              implicitly added to this list; i.e. there is no need to list them.
629
630                .RS 2
631                # Key added on: 2011-07-20 20:38:46
632                # Fingerprint:  5e:8d:c4:ad:e7:af:6e:27:8a:d6:13:e4:79:ad:0b:81
633                34B62F25E277CF13D3C6BCEBFD3F85D08F0A864B 0 confirm
634                .fi
635
636
637       private-keys-v1.d/
638
639                This is the directory where gpg-agent stores the private keys.  Each
640                key is stored in a file with the name made up of the keygrip and the
641                suffix ‘key’.  You should backup all files in this directory
642                and take great care to keep this backup closed away.
643
644
645
646              Note that on larger installations, it is useful to put predefined
647              files into the directory ‘/etc/skel/.gnupg/’ so that newly created
648              users start up with a working configuration.  For existing users the
649              a small helper script is provided to create these files (see: [addgnupghome]).
650
651
652
653
654

SIGNALS

656       A  running  gpg-agent may be controlled by signals, i.e. using the kill
657       command to send a signal to the process.
658
659       Here is a list of supported signals:
660
661
662
663       SIGHUP This signal flushes all cached passphrases and  if  the  program
664              has  been  started  with a configuration file, the configuration
665              file is read again.  Only certain options  are  honored:  quiet,
666              verbose,  debug,  debug-all, debug-level, no-grab, pinentry-pro‐
667              gram, default-cache-ttl,  max-cache-ttl,  ignore-cache-for-sign‐
668              ing,  allow-mark-trusted and disable-scdaemon.  scdaemon-program
669              is also supported but due to the current  implementation,  which
670              calls  the  scdaemon only once, it is not of much use unless you
671              manually kill the scdaemon.
672
673
674
675       SIGTERM
676              Shuts down the process but waits until all current requests  are
677              fulfilled.   If  the process has received 3 of these signals and
678              requests are still pending, a shutdown is forced.
679
680
681       SIGINT Shuts down the process immediately.
682
683
684       SIGUSR1
685              Dump internal information to the log file.
686
687
688       SIGUSR2
689              This signal is used for internal purposes.
690
691
692
693

SEE ALSO

695       gpg2(1), gpgsm(1), gpg-connect-agent(1), scdaemon(1)
696
697       The full documentation for this tool is maintained as a Texinfo manual.
698       If  GnuPG and the info program are properly installed at your site, the
699       command
700
701         info gnupg
702
703       should give you access to the complete manual including a  menu  struc‐
704       ture and an index.
705
706
707
708GnuPG 2.0.18                      2011-09-20                      GPG-AGENT(1)
Impressum