     [file defs.inc not included]

Helper Tools
************

GnuPG comes with a couple of smaller tools:

watchgnupg.1

Read logs from a socket
=======================

synopsis

description
Most of the main utilities are able to write their log files to a Unix Domain socket if configured that way.  watchgnupg is a simple listener for such a socket.  It ameliorates the output with a time stamp and makes sure that long lines are not interspersed with log output from other utilities.  This tool is not available for Windows.

watchgnupg is commonly invoked as

     watchgnupg --force $(gpgconf --list-dirs socketdir)/S.log

This starts it on the current terminal for listening on the standard logging socket (which is either ~/.gnupg/S.log or /var/run/user/UID/gnupg/S.log).

options

watchgnupg understands these options:

--force
     Delete an already existing socket file.

--tcp N
     Instead of reading from a local socket, listen for connects on TCP port N.

--time-only
     Do not print the date part of the timestamp.

--verbose
     Enable extra informational output.

--version
     Print version of the program and exit.

--help
     Display a brief help page and exit.

examples

Examples
********

     $ watchgnupg --force --time-only $(gpgconf --list-dirs socketdir)/S.log

This waits for connections on the local socket (e.g. /home/foo/.gnupg/S.log) and shows all log entries.  To make this work the option log-file needs to be used with all modules which logs are to be shown.  The suggested entry for the configuration files is:

     log-file socket://

If the default socket as given above and returned by "echo $(gpgconf --list-dirs socketdir)/S.log" is not desired an arbitrary socket name can be specified, for example socket:///home/foo/bar/mysocket. For debugging purposes it is also possible to do remote logging.  Take care if you use this feature because the information is send in the clear over the network.  Use this syntax in the conf files:

     log-file tcp://192.168.1.1:4711

You may use any port and not just 4711 as shown above; only IP addresses are supported (v4 and v6) and no host names.  You need to start watchgnupg with the tcp option.  Note that under Windows the registry entry HKCU\SOFTWARE\GNU\GNUPG:DEFAULTLOGFILE can be used to change the default log output from stderr to whatever is given by that entry.  However the only useful entry is a TCP name for remote debugging.

see also
     [file see-also-note.texi not included]

     [file gpgv.texi not included]

addgnupghome.8

Create .gnupg home directories
==============================

synopsis

description
If GnuPG is installed on a system with existing user accounts, it is sometimes required to populate the GnuPG home directory with existing files.  Especially a trustlist.txt and a keybox with some initial certificates are often desired.  This script helps to do this by copying all files from /etc/skel/.gnupg to the home directories of the accounts given on the command line.  It takes care not to overwrite existing GnuPG home directories.

addgnupghome is invoked by root as:

     addgnupghome account1 account2 ... accountn

gpgconf.1

Modify .gnupg home directories
==============================

synopsis

description
The gpgconf is a utility to automatically and reasonable safely query and modify configuration files in the .gnupg home directory.  It is designed not to be invoked manually by the user, but automatically by graphical user interfaces (GUI). (Please note that currently no locking is done, so concurrent access should be avoided.  There are some precautions to avoid corruption with concurrent usage, but results may be inconsistent and some changes may get lost.  The stateless design makes it difficult to provide more guarantees.)

gpgconf provides access to the configuration of one or more components of the GnuPG system.  These components correspond more or less to the programs that exist in the GnuPG framework, like GPG, GPGSM, DirMngr, etc.  But this is not a strict one-to-one relationship.  Not all configuration options are available through gpgconf.  gpgconf provides a generic and abstract method to access the most important configuration options that can feasibly be controlled via such a mechanism.

gpgconf can be used to gather and change the options available in each component, and can also provide their default values.  gpgconf will give detailed type information that can be used to restrict the user's input without making an attempt to commit the changes.

gpgconf provides the backend of a configuration editor.  The configuration editor would usually be a graphical user interface program that displays the current options, their default values, and allows the user to make changes to the options.  These changes can then be made active with gpgconf again.  Such a program that uses gpgconf in this way will be called GUI throughout this section.

Invoking gpgconf
----------------

commands
One of the following commands must be given:

--list-components
     List all components.  This is the default command used if none is specified.

--check-programs
     List all available backend programs and test whether they are runnable.

--list-options COMPONENT
     List all options of the component COMPONENT.

--change-options COMPONENT
     Change the options of the component COMPONENT.

--check-options COMPONENT
     Check the options for the component COMPONENT.

--apply-profile FILE
     Apply the configuration settings listed in FILE to the configuration files.  If FILE has no suffix and no slashes the command first tries to read a file with the suffix .prf from the the data directory (gpgconf --list-dirs datadir) before it reads the file verbatim.  A profile is divided into sections using the bracketed  component name.  Each section then lists the option which shall go into the respective configuration file.

--apply-defaults
     Update all configuration files with values taken from the global configuration file (usually /etc/gnupg/gpgconf.conf).

--list-dirs [NAMES]
     Lists the directories used by gpgconf.  One directory is listed per line, and each line consists of a colon-separated list where the first field names the directory type (for example sysconfdir) and the second field contains the percent-escaped directory.  Although they are not directories, the socket file names used by gpg-agent and dirmngr are printed as well.  Note that the socket file names and the homedir lines are the default names and they may be overridden by command line switches.  If NAMES are given only the directories or file names specified by the list names are printed without any escaping.

--list-config [FILENAME]
     List the global configuration file in a colon separated format.  If FILENAME is given, check that file instead.

--check-config [FILENAME]
     Run a syntax check on the global configuration file.  If FILENAME is given, check that file instead.

--query-swdb PACKAGE_NAME [VERSION_STRING]
     Returns the current version for PACKAGE_NAME and if VERSION_STRING is given also an indicator on whether an update is available.  The actual file with the software version is automatically downloaded and checked by dirmngr. dirmngr uses a thresholds to avoid download the file too often and it does this by default only if it can be done via Tor.  To force an update of that file this command can be used:

                 gpg-connect-agent --dirmngr 'loadswdb --force' /bye

--reload [COMPONENT]
     Reload all or the given component. This is basically the same as sending a SIGHUP to the component.  Components which don't support reloading are ignored.  Without COMPONENT or by using "all" for COMPONENT all components which are daemons are reloaded.

--launch [COMPONENT]
     If the COMPONENT is not already running, start it. component must be a daemon.  This is in general not required because the system starts these daemons as needed.  However, external software making direct use of gpg-agent or dirmngr may use this command to ensure that they are started.  Using "all" for COMPONENT launches all components which are daemons.

--kill [COMPONENT]
     Kill the given component.  Components which support killing are gpg-agent and scdaemon.  Components which don't support reloading are ignored.  Using "all" for COMPONENT kills all components running as daemons.  Note that as of now reload and kill have the same effect for scdaemon.

--create-socketdir
     Create a directory for sockets below /run/user or /var/run/user.  This is command is only required if a non default home directory is used and the /run based sockets shall be used.  For the default home directory GnUPG creates a directory on the fly.

--remove-socketdir
     Remove a directory created with command --create-socketdir.

options

The following options may be used:

-o FILE
--output FILE
     Write output to FILE.  Default is to write to stdout.

-v
--verbose
     Outputs additional information while running.  Specifically, this extends numerical field values by human-readable descriptions.

-q
--quiet
     Try to be as quiet as possible.

-n
--dry-run
     Do not actually change anything.  This is currently only implemented for --change-options and can be used for testing purposes.

-r
--runtime
     Only used together with --change-options.  If one of the modified options can be changed in a running daemon process, signal the running daemon to ask it to reparse its configuration file after changing.

     This means that the changes will take effect at run-time, as far as this is possible.  Otherwise, they will take effect at the next start of the respective backend programs.

Format conventions
------------------

Some lines in the output of gpgconf contain a list of colon-separated fields.  The following conventions apply:

  * The GUI program is required to strip off trailing newline and/or carriage return characters from the output.

  * gpgconf will never leave out fields.  If a certain version provides a certain field, this field will always be present in all gpgconf versions from that time on.

  * Future versions of gpgconf might append fields to the list. New fields will always be separated from the previously last field by a colon separator.  The GUI should be prepared to parse the last field it knows about up until a colon or end of line.

  * Not all fields are defined under all conditions.  You are required to ignore the content of undefined fields.

There are several standard types for the content of a field:

verbatim
     Some fields contain strings that are not escaped in any way.  Such fields are described to be used verbatim.  These fields will never contain a colon character (for obvious reasons).  No de-escaping or other formatting is required to use the field content.  This is for easy parsing of the output, when it is known that the content can never contain any special characters.

percent-escaped
     Some fields contain strings that are described to be percent-escaped.  Such strings need to be de-escaped before their content can be presented to the user.  A percent-escaped string is de-escaped by replacing all occurrences of %XY by the byte that has the hexadecimal value XY.  X and Y are from the set 0-9a-f.

localized
     Some fields contain strings that are described to be localized. Such strings are translated to the active language and formatted in the active character set.

unsigned number
     Some fields contain an unsigned number.  This number will always fit into a 32-bit unsigned integer variable.  The number may be followed by a space, followed by a human readable description of that value (if the verbose option is used).  You should ignore everything in the field that follows the number.

signed number
     Some fields contain a signed number.  This number will always fit into a 32-bit signed integer variable.  The number may be followed by a space, followed by a human readable description of that value (if the verbose option is used).  You should ignore everything in the field that follows the number.

boolean value
     Some fields contain a boolean value.  This is a number with either the value 0 or 1.  The number may be followed by a space, followed by a human readable description of that value (if the verbose option is used).  You should ignore everything in the field that follows the number; checking just the first character is sufficient in this case.

option argument
     Some fields contain an option argument.  The format of an option argument depends on the type of the option and on some flags:

     no argument
          The simplest case is that the option does not take an argument at all (TYPE 0).  Then the option argument is an unsigned number that specifies how often the option occurs.  If the list flag is not set, then the only valid number is 1.  Options that do not take an argument never have the default or optional arg flag set.

     number
          If the option takes a number argument (ALT-TYPE is 2 or 3), and it can only occur once (list flag is not set), then the option argument is either empty (only allowed if the argument is optional), or it is a number.  A number is a string that begins with an optional minus character, followed by one or more digits.  The number must fit into an integer variable (unsigned or signed, depending on ALT-TYPE).

     number list
          If the option takes a number argument and it can occur more than once, then the option argument is either empty, or it is a comma-separated list of numbers as described above.

     string
          If the option takes a string argument (ALT-TYPE is 1), and it can only occur once (list flag is not set) then the option argument is either empty (only allowed if the argument is optional), or it starts with a double quote character (") followed by a percent-escaped string that is the argument value.  Note that there is only a leading double quote character, no trailing one.  The double quote character is only needed to be able to differentiate between no value and the empty string as value.

     string list
          If the option takes a string argument and it can occur more than once, then the option argument is either empty, or it is a comma-separated list of string arguments as described above.

The active language and character set are currently determined from the locale environment of the gpgconf program.

usage

Listing components
------------------

The command --list-components will list all components that can be configured with gpgconf.  Usually, one component will correspond to one GnuPG-related program and contain the options of that program's configuration file that can be modified using gpgconf.  However, this is not necessarily the case.  A component might also be a group of selected options from several programs, or contain entirely virtual options that have a special effect rather than changing exactly one option in one configuration file.

A component is a set of configuration options that semantically belong together.  Furthermore, several changes to a component can be made in an atomic way with a single operation.  The GUI could for example provide a menu with one entry for each component, or a window with one tabulator sheet per component.

The command --list-components lists all available components, one per line.  The format of each line is:

NAME:DESCRIPTION:PGMNAME:

name
     This field contains a name tag of the component.  The name tag is used to specify the component in all communication with gpgconf. The name tag is to be used verbatim.  It is thus not in any escaped format.

description
     The string in this field contains a human-readable description of the component.  It can be displayed to the user of the GUI for informational purposes.  It is percent-escaped and localized.

pgmname
     The string in this field contains the absolute name of the program's file.  It can be used to unambiguously invoke that program. It is percent-escaped.

Example:

     $ gpgconf --list-components
     gpg:GPG for OpenPGP:/usr/local/bin/gpg2:
     gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:
     scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:
     gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:
     dirmngr:Directory Manager:/usr/local/bin/dirmngr:

Checking programs
-----------------

The command --check-programs is similar to --list-components but works on backend programs and not on components.  It runs each program to test whether it is installed and runnable.  This also includes a syntax check of all config file options of the program.

The command --check-programs lists all available programs, one per line.  The format of each line is:

NAME:DESCRIPTION:PGMNAME:AVAIL:OKAY:CFGFILE:LINE:ERROR:

name
     This field contains a name tag of the program which is identical to the name of the component.  The name tag is to be used verbatim.  It is thus not in any escaped format.  This field may be empty to indicate a continuation of error descriptions for the last name.  The description and pgmname fields are then also empty.

description
     The string in this field contains a human-readable description of the component.  It can be displayed to the user of the GUI for informational purposes.  It is percent-escaped and localized.

pgmname
     The string in this field contains the absolute name of the program's file.  It can be used to unambiguously invoke that program. It is percent-escaped.

avail
     The boolean value in this field indicates whether the program is installed and runnable.

okay
     The boolean value in this field indicates whether the program's config file is syntactically okay.

cfgfile
     If an error occurred in the configuration file (as indicated by a false value in the field okay), this field has the name of the failing configuration file.  It is percent-escaped.

line
     If an error occurred in the configuration file, this field has the line number of the failing statement in the configuration file. It is an unsigned number.

error
     If an error occurred in the configuration file, this field has the error text of the failing statement in the configuration file.  It is percent-escaped and localized.

In the following example the dirmngr is not runnable and the configuration file of scdaemon is not okay.

     $ gpgconf --check-programs
     gpg:GPG for OpenPGP:/usr/local/bin/gpg2:1:1:
     gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:1:1:
     scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:1:0:
     gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:1:1:
     dirmngr:Directory Manager:/usr/local/bin/dirmngr:0:0:

The command --check-options COMPONENT will verify the configuration file in the same manner as --check-programs, but only for the component COMPONENT.

Listing options
---------------

Every component contains one or more options.  Options may be gathered into option groups to allow the GUI to give visual hints to the user about which options are related.

The command --list-options COMPONENT lists all options (and the groups they belong to) in the component COMPONENT, one per line.  COMPONENT must be the string in the field NAME in the output of the --list-components command.

There is one line for each option and each group.  First come all options that are not in any group.  Then comes a line describing a group.  Then come all options that belong into each group.  Then comes the next group and so on.  There does not need to be any group (and in this case the output will stop after the last non-grouped option).

The format of each line is:

NAME:FLAGS:LEVEL:DESCRIPTION:TYPE:ALT-TYPE:ARGNAME:DEFAULT:ARGDEF:VALUE

name
     This field contains a name tag for the group or option.  The name tag is used to specify the group or option in all communication with gpgconf.  The name tag is to be used verbatim.  It is thus not in any escaped format.

flags
     The flags field contains an unsigned number.  Its value is the OR-wise combination of the following flag values:

     group (1)
          If this flag is set, this is a line describing a group and not an option.

     The following flag values are only defined for options (that is, if the group flag is not used).

     optional arg (2)
          If this flag is set, the argument is optional.  This is never set for TYPE 0 (none) options.

     list (4)
          If this flag is set, the option can be given multiple times.

     runtime (8)
          If this flag is set, the option can be changed at runtime.

     default (16)
          If this flag is set, a default value is available.

     default desc (32)
          If this flag is set, a (runtime) default is available.  This and the default flag are mutually exclusive.

     no arg desc (64)
          If this flag is set, and the optional arg flag is set, then the option has a special meaning if no argument is given.

     no change (128)
          If this flag is set, gpgconf ignores requests to change the value.  GUI frontends should grey out this option.  Note, that manual changes of the configuration files are still possible.

level
     This field is defined for options and for groups.  It contains an unsigned number that specifies the expert level under which this group or option should be displayed.  The following expert levels are defined for options (they have analogous meaning for groups):

     basic (0)
          This option should always be offered to the user.

     advanced (1)
          This option may be offered to advanced users.

     expert (2)
          This option should only be offered to expert users.

     invisible (3)
          This option should normally never be displayed, not even to expert users.

     internal (4)
          This option is for internal use only.  Ignore it.

     The level of a group will always be the lowest level of all options it contains.

description
     This field is defined for options and groups.  The string in this field contains a human-readable description of the option or group.  It can be displayed to the user of the GUI for informational purposes.  It is percent-escaped and localized.

type
     This field is only defined for options.  It contains an unsigned number that specifies the type of the option's argument, if any.  The following types are defined:

     Basic types:

     none (0)
          No argument allowed.

     string (1)
          An unformatted string.

     int32 (2)
          A signed number.

     uint32 (3)
          An unsigned number.

     Complex types:

     pathname (32)
          A string that describes the pathname of a file.  The file does not necessarily need to exist.

     ldap server (33)
          A string that describes an LDAP server in the format:

          HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN

     key fingerprint (34)
          A string with a 40 digit fingerprint specifying a certificate.

     pub key (35)
          A string that describes a certificate by user ID, key ID or fingerprint.

     sec key (36)
          A string that describes a certificate with a key by user ID, key ID or fingerprint.

     alias list (37)
          A string that describes an alias list, like the one used with gpg's group option.  The list consists of a key, an equal sign and space separated values.

     More types will be added in the future.  Please see the ALT-TYPE field for information on how to cope with unknown types.

alt-type
     This field is identical to TYPE, except that only the types 0 to 31 are allowed.  The GUI is expected to present the user the option in the format specified by TYPE.  But if the argument type TYPE is not supported by the GUI, it can still display the option in the more generic basic type ALT-TYPE.  The GUI must support all the defined basic types to be able to display all options.  More basic types may be added in future versions.  If the GUI encounters a basic type it doesn't support, it should report an error and abort the operation.

argname
     This field is only defined for options with an argument type TYPE that is not 0.  In this case it may contain a percent-escaped and localized string that gives a short name for the argument.  The field may also be empty, though, in which case a short name is not known.

default
     This field is defined only for options for which the default or default desc flag is set.  If the default flag is set, its format is that of an option argument (see Format conventions, for details).  If the default value is empty, then no default is known.  Otherwise, the value specifies the default value for this option.  If the default desc flag is set, the field is either empty or contains a description of the effect if the option is not given.

argdef
     This field is defined only for options for which the optional arg flag is set.  If the no arg desc flag is not set, its format is that of an option argument (see Format conventions, for details).  If the default value is empty, then no default is known.  Otherwise, the value specifies the default argument for this option.  If the no arg desc flag is set, the field is either empty or contains a description of the effect of this option if no argument is given.

value
     This field is defined only for options.  Its format is that of an option argument.  If it is empty, then the option is not explicitly set in the current configuration, and the default applies (if any).  Otherwise, it contains the current value of the option. Note that this field is also meaningful if the option itself does not take a real argument (in this case, it contains the number of times the option appears).

Changing options
----------------

The command --change-options COMPONENT will attempt to change the options of the component COMPONENT to the specified values.  COMPONENT must be the string in the field NAME in the output of the --list-components command.  You have to provide the options that shall be changed in the following format on standard input:

NAME:FLAGS:NEW-VALUE

name
     This is the name of the option to change.  NAME must be the string in the field NAME in the output of the --list-options command.

flags
     The flags field contains an unsigned number.  Its value is the OR-wise combination of the following flag values:

     default (16)
          If this flag is set, the option is deleted and the default value is used instead (if applicable).

new-value
     The new value for the option.  This field is only defined if the default flag is not set.  The format is that of an option argument.  If it is empty (or the field is omitted), the default argument is used (only allowed if the argument is optional for this option).  Otherwise, the option will be set to the specified value.

The output of the command is the same as that of --check-options for the modified configuration file.

Examples:

To set the force option, which is of basic type none (0):

     $ echo 'force:0:1' | gpgconf --change-options dirmngr

To delete the force option:

     $ echo 'force:16:' | gpgconf --change-options dirmngr

The --runtime option can influence when the changes take effect.

Listing global options
----------------------

Sometimes it is useful for applications to look at the global options file gpgconf.conf. The colon separated listing format is record oriented and uses the first field to identify the record type:

k
     This describes a key record to start the definition of a new ruleset for a user/group.  The format of a key record is:

     k:USER:GROUP:

     user
          This is the user field of the key.  It is percent escaped.  See the definition of the gpgconf.conf format for details.

     group
          This is the group field of the key.  It is percent escaped.

r
     This describes a rule record. All rule records up to the next key record make up a rule set for that key.  The format of a rule record is:

     r:::COMPONENT:OPTION:FLAG:VALUE:

     component
          This is the component part of a rule.  It is a plain string.

     option
          This is the option part of a rule.  It is a plain string.

     flag
          This is the flags part of a rule.  There may be only one flag per rule but by using the same component and option, several flags may be assigned to an option.  It is a plain string.

     value
          This is the optional value for the option.  It is a percent escaped string with a single quotation mark to indicate a string.  The quotation mark is only required to distinguish between no value specified and an empty string.

Unknown record types should be ignored.  Note that there is intentionally no feature to change the global option file through gpgconf.

Get and compare software versions.
----------------------------------

The GnuPG Project operates a server to query the current versions of software packages related to GnuPG.  gpgconf can be used to access this online database.  To allow for offline operations, this feature works by having dirmngr download a file from https://versions.gnupg.org, checking the signature of that file and storing the file in the GnuPG home directory.  If gpgconf is used and dirmngr is running, it may ask dirmngr to refresh that file before itself uses the file.

The command --query-swdb returns information for the given package in a colon delimited format:

name
     This is the name of the package as requested.  Note that "gnupg" is a special name which is replaced by the actual package implementing this version of GnuPG.  For this name it is also not required to specify a version because gpgconf takes its own version in this case.

iversion
     The currently installed version or an empty string.  The value is taken from the command line argument but may be provided by gpg if not given.

status
     The status of the software package according to this table:

     -
          No information available.  This is either because no current version has been specified or due to an error.

     ?
          The given name is not known in the online database.

     u
          An update of the software is available.

     c
          The installed version of the software is current.

     n
          The installed version is already newer than the released version.

urgency
     If the value (the empty string should be considered as zero) is greater than zero an important update is available.

error
     This returns an gpg-error error code to distinguish between various failure modes.

filedate
     This gives the date of the file with the version numbers in standard ISO format (yyyymmddThhmmss).  The date has been extracted by dirmngr from the signature of the file.

verified
     This gives the date in ISO format the file was downloaded.  This value can be used to evaluate the freshness of the information.

version
     This returns the version string for the requested software from the file.

reldate
     This returns the release date in ISO format.

size
     This returns the size of the package as decimal number of bytes.

hash
     This returns a hexified SHA-2 hash of the package.

More fields may be added in future to the output.

files

Files used by gpgconf
---------------------

/etc/gnupg/gpgconf.conf
     If this file exists, it is processed as a global configuration file. A commented example can be found in the examples directory of the distribution.

GNUPGHOME/swdb.lst
     A file with current software versions.  dirmngr creates this file on demand from an online resource.

see also
     [file see-also-note.texi not included]

applygnupgdefaults.8

Run gpgconf for all users
=========================

synopsis

description
This script is a wrapper around gpgconf to run it with the command --apply-defaults for all real users with an existing GnuPG home directory.  Admins might want to use this script to update he GnuPG configuration files for all users after /etc/gnupg/gpgconf.conf has been changed.  This allows enforcing certain policies for all users.  Note, that this is not a bulletproof way to force a user to use certain options.  A user may always directly edit the configuration files and bypass gpgconf.

applygnupgdefaults is invoked by root as:

     applygnupgdefaults

Put a passphrase into the cache
===============================

gpg-preset-passphrase.1

synopsis

description
The gpg-preset-passphrase is a utility to seed the internal cache of a running gpg-agent with passphrases.  It is mainly useful for unattended machines, where the usual pinentry tool may not be used and the passphrases for the to be used keys are given at machine startup.

Passphrases set with this utility don't expire unless the --forget option is used to explicitly clear them from the cache --- or gpg-agent is either restarted or reloaded (by sending a SIGHUP to it).  Note that the maximum cache time as set with --max-cache-ttl is still honored.  It is necessary to allow this passphrase presetting by starting gpg-agent with the --allow-preset-passphrase.

List of all commands and options
--------------------------------

gpg-preset-passphrase is invoked this way:

     gpg-preset-passphrase [options] [command] CACHEID

CACHEID is either a 40 character keygrip of hexadecimal characters identifying the key for which the passphrase should be set or cleared.  The keygrip is listed along with the key when running the command: gpgsm --dump-secret-keys.  Alternatively an arbitrary string may be used to identify a passphrase; it is suggested that such a string is prefixed with the name of the application (e.g foo:12346).

One of the following command options must be given:

--preset
     Preset a passphrase. This is what you usually will use. gpg-preset-passphrase will then read the passphrase from stdin.

--forget
     Flush the passphrase for the given cache ID from the cache.

The following additional options may be used:

-v
--verbose
     Output additional information while running.

-P STRING
--passphrase STRING
     Instead of reading the passphrase from stdin, use the supplied STRING as passphrase.  Note that this makes the passphrase visible for other users.

see also
     [file see-also-note.texi not included]

Communicate with a running agent
================================

gpg-connect-agent.1

synopsis

description
The gpg-connect-agent is a utility to communicate with a running gpg-agent.  It is useful to check out the commands gpg-agent provides using the Assuan interface.  It might also be useful for scripting simple applications.  Input is expected at stdin and output gets printed to stdout.

It is very similar to running gpg-agent in server mode; but here we connect to a running instance.

List of all options
-------------------

gpg-connect-agent is invoked this way:

     gpg-connect-agent [options] [commands]

The following options may be used:

-v
--verbose
     Output additional information while running.

-q

--quiet
     Try to be as quiet as possible.

          [file opt-homedir.texi not included]

--agent-program FILE
     Specify the agent program to be started if none is running.  The default value is determined by running gpgconf with the option --list-dirs.  Note that the pipe symbol (|) is used for a regression test suite hack and may thus not be used in the file name.

--dirmngr-program FILE
     Specify the directory manager (keyserver client) program to be started if none is running.  This has only an effect if used together with the option --dirmngr.

--dirmngr
     Connect to a running directory manager (keyserver client) instead of to the gpg-agent.  If a dirmngr is not running, start it.

-S
--raw-socket NAME
     Connect to socket NAME assuming this is an Assuan style server. Do not run any special initializations or environment checks.  This may be used to directly connect to any Assuan style socket server.

-E
--exec
     Take the rest of the command line as a program and it's arguments and execute it as an Assuan server. Here is how you would run gpgsm:

           gpg-connect-agent --exec gpgsm --server

     Note that you may not use options on the command line in this case.

--no-ext-connect
     When using -S or --exec, gpg-connect-agent connects to the Assuan server in extended mode to allow descriptor passing.  This option makes it use the old mode.

--no-autostart
     Do not start the gpg-agent or the dirmngr if it has not yet been started.

-r FILE
--run FILE
     Run the commands from FILE at startup and then continue with the regular input method.  Note, that commands given on the command line are executed after this file.

-s
--subst
     Run the command /subst at startup.

--hex
     Print data lines in a hex format and the ASCII representation of non-control characters.

--decode
     Decode data lines.  That is to remove percent escapes but make sure that a new line always starts with a D and a space.

control commands

Control commands
----------------

While reading Assuan commands, gpg-agent also allows a few special commands to control its operation.  These control commands all start with a slash (/).

/echo ARGS
     Just print ARGS.

/let NAME VALUE
     Set the variable NAME to VALUE.  Variables are only substituted on the input if the /subst has been used. Variables are referenced by prefixing the name with a dollar sign and optionally include the name in curly braces.  The rules for a valid name are identically to those of the standard bourne shell.  This is not yet enforced but may be in the future.  When used with curly braces no leading or trailing white space is allowed.

     If a variable is not found, it is searched in the environment and if found copied to the table of variables.

     Variable functions are available: The name of the function must be followed by at least one space and the at least one argument.  The following functions are available:

     get
          Return a value described by the argument.  Available arguments are:

          cwd
               The current working directory.

          homedir
               The gnupg homedir.

          sysconfdir
               GnuPG's system configuration directory.

          bindir
               GnuPG's binary directory.

          libdir
               GnuPG's library directory.

          libexecdir
               GnuPG's library directory for executable files.

          datadir
               GnuPG's data directory.

          serverpid
               The PID of the current server. Command /serverpid must have been given to return a useful value.

     unescape ARGS
          Remove C-style escapes from ARGS.  Note that \0 and \x00 terminate the returned string implicitly.  The string to be converted are the entire arguments right behind the delimiting space of the function name.

     unpercent ARGS
     unpercent+ ARGS
          Remove percent style escaping from ARGS.  Note that %00 terminates the string implicitly.  The string to be converted are the entire arguments right behind the delimiting space of the function name. unpercent+ also maps plus signs to a spaces.

     percent ARGS
     percent+ ARGS
          Escape the ARGS using percent style escaping.  Tabs, formfeeds, linefeeds, carriage returns and colons are escaped. percent+ also maps spaces to plus signs.

     errcode ARG
     errsource ARG
     errstring ARG
          Assume ARG is an integer and evaluate it using strtol.  Return the gpg-error error code, error source or a formatted string with the error code and error source.

     +
     -
     *
     /
     %
          Evaluate all arguments as long integers using strtol and apply this operator.  A division by zero yields an empty string.

     !
     |
     &
          Evaluate all arguments as long integers using strtol and apply the logical operators NOT, OR or AND.  The NOT operator works on the last argument only.

/definq NAME VAR
     Use content of the variable VAR for inquiries with NAME. NAME may be an asterisk (*) to match any inquiry.

/definqfile NAME FILE
     Use content of FILE for inquiries with NAME. NAME may be an asterisk (*) to match any inquiry.

/definqprog NAME PROG
     Run PROG for inquiries matching NAME and pass the entire line to it as command line arguments.

/datafile NAME
     Write all data lines from the server to the file NAME.  The file is opened for writing and created if it does not exists.  An existing file is first truncated to 0.  The data written to the file fully decoded.  Using a single dash for NAME writes to stdout.  The file is kept open until a new file is set using this command or this command is used without an argument.

/showdef
     Print all definitions

/cleardef
     Delete all definitions

/sendfd FILE MODE
     Open FILE in MODE (which needs to be a valid fopen mode string) and send the file descriptor to the server.  This is usually followed by a command like INPUT FD to set the input source for other commands.

/recvfd
     Not yet implemented.

/open VAR FILE [MODE]
     Open FILE and assign the file descriptor to VAR.  Warning: This command is experimental and might change in future versions.

/close FD
     Close the file descriptor FD.  Warning: This command is experimental and might change in future versions.

/showopen
     Show a list of open files.

/serverpid
     Send the Assuan command GETINFO pid to the server and store the returned PID for internal purposes.

/sleep
     Sleep for a second.

/hex
/nohex
     Same as the command line option --hex.

/decode
/nodecode
     Same as the command line option --decode.

/subst
/nosubst
     Enable and disable variable substitution.  It defaults to disabled unless the command line option --subst has been used. If /subst as been enabled once, leading whitespace is removed from input lines which makes scripts easier to read.

/while CONDITION
/end
     These commands provide a way for executing loops.  All lines between the while and the corresponding end are executed as long as the evaluation of CONDITION yields a non-zero value or is the string true or yes.  The evaluation is done by passing CONDITION to the strtol function.  Example:

            /subst
            /let i 3
            /while $i
              /echo loop couter is $i
              /let i ${- $i 1}
            /end

/if CONDITION
/end
     These commands provide a way for conditional execution.  All lines between the if and the corresponding end are executed only if the evaluation of CONDITION yields a non-zero value or is the string true or yes.  The evaluation is done by passing CONDITION to the strtol function.

/run FILE
     Run commands from FILE.

/bye
     Terminate the connection and the program.

/help
     Print a list of available control commands.

The Dirmngr Client Tool
=======================

dirmngr-client.1

synopsis

description
The dirmngr-client is a simple tool to contact a running dirmngr and test whether a certificate has been revoked --- either by being listed in the corresponding CRL or by running the OCSP protocol. If no dirmngr is running, a new instances will be started but this is in general not a good idea due to the huge performance overhead.

The usual way to run this tool is either:

     dirmngr-client ACERT

or

     dirmngr-client <ACERT

Where ACERT is one DER encoded (binary) X.509 certificates to be tested. The return value of this command is

return value

0
     The certificate under question is valid; i.e. there is a valid CRL available and it is not listed there or the OCSP request returned that that certificate is valid.

1
     The certificate has been revoked

2 (and other values)
     There was a problem checking the revocation state of the certificate. A message to stderr has given more detailed information.  Most likely this is due to a missing or expired CRL or due to a network problem.

options

dirmngr-client may be called with the following options:

--version
     Print the program version and licensing information.  Note that you cannot abbreviate this command.

--help, -h
     Print a usage message summarizing the most useful command-line options. Note that you cannot abbreviate this command.

--quiet, -q
     Make the output extra brief by suppressing any informational messages.

-v

--verbose
     Outputs additional information while running. You can increase the verbosity by giving several verbose commands to DIRMNGR, such as -vv.

--pem
     Assume that the given certificate is in PEM (armored) format.

--ocsp
     Do the check using the OCSP protocol and ignore any CRLs.

--force-default-responder
     When checking using the OCSP protocol, force the use of the default OCSP responder.  That is not to use the Reponder as given by the certificate.

--ping
     Check whether the dirmngr daemon is up and running.

--cache-cert
     Put the given certificate into the cache of a running dirmngr.  This is mainly useful for debugging.

--validate
     Validate the given certificate using dirmngr's internal validation code. This is mainly useful for debugging.

--load-crl
     This command expects a list of filenames with DER encoded CRL files. With the option --url URLs are expected in place of filenames and they are loaded directly from the given location.  All CRLs will be validated and then loaded into dirmngr's cache.

--lookup
     Take the remaining arguments and run a lookup command on each of them. The results are Base-64 encoded outputs (without header lines).  This may be used to retrieve certificates from a server. However the output format is not very well suited if more than one certificate is returned.

--url
-u
     Modify the lookup and load-crl commands to take an URL.

--local
-l
     Let the lookup command only search the local cache.

--squid-mode
     Run DIRMNGR-CLIENT in a mode suitable as a helper program for Squid's external_acl_type option.

Parse a mail message into an annotated format
=============================================

gpgparsemail.1

synopsis

description
The gpgparsemail is a utility currently only useful for debugging.  Run it with --help for usage information.

Call a simple symmetric encryption tool
=======================================

symcryptrun.1

synopsis

description
Sometimes simple encryption tools are already in use for a long time and there might be a desire to integrate them into the GnuPG framework.  The protocols and encryption methods might be non-standard or not even properly documented, so that a full-fledged encryption tool with an interface like gpg is not doable. symcryptrun provides a solution: It operates by calling the external encryption/decryption module and provides a passphrase for a key using the standard pinentry based mechanism through gpg-agent.

Note, that symcryptrun is only available if GnuPG has been configured with --enable-symcryptrun at build time.

List of all commands and options
--------------------------------

symcryptrun is invoked this way:

     symcryptrun --class CLASS --program PROGRAM --keyfile KEYFILE
        [--decrypt | --encrypt] [inputfile]

For encryption, the plain text must be provided on STDIN or as the argument INPUTFILE, and the ciphertext will be output to STDOUT. For decryption vice versa.

CLASS describes the calling conventions of the external tool. Currently it must be given as confucius.  PROGRAM is the full filename of that external tool.

For the class confucius the option --keyfile is required; KEYFILE is the name of a file containing the secret key, which may be protected by a passphrase.  For detailed calling conventions, see the source code.

Note, that gpg-agent must be running before starting symcryptrun.

The following additional options may be used:

-v
--verbose
     Output additional information while running.

-q

--quiet
     Try to be as quiet as possible.

          [file opt-homedir.texi not included]

--log-file FILE
     Append all logging output to FILE.  Use socket:// to log to socket.  Default is to write logging information to STDERR.

The possible exit status codes of symcryptrun are:

0
     Success.

1
     Some error occurred.

2
     No valid passphrase was provided.

3
     The operation was canceled by the user.

see also
     [file see-also-note.texi not included]

gpg-zip.1

Encrypt or sign files into an archive
=====================================

synopsis

description
gpg-zip encrypts or signs files into an archive.  It is an gpg-ized tar using the same format as used by PGP's PGP Zip.

gpg-zip is invoked this way:

     gpg-zip [options] FILENAME1 [FILENAME2, ...] DIRECTORY [DIRECTORY2, ...]

options

gpg-zip understands these options:

--encrypt
-e
     Encrypt data.  This option may be combined with --symmetric (for  output that may be decrypted via a secret key or a passphrase).

--decrypt
-d
     Decrypt data.

--symmetric
-c
     Encrypt with a symmetric cipher using a passphrase.  The default symmetric cipher used is CAST5, but may be chosen with the --cipher-algo option to gpg.

--sign
-s
     Make a signature.  See gpg.

--recipient USER
-r USER
     Encrypt for user id USER. See gpg.

--local-user USER
-u USER
     Use USER as the key to sign with.  See gpg.

--list-archive
     List the contents of the specified archive.

--output FILE
-o FILE
     Write output to specified file FILE.

--gpg GPGCMD
     Use the specified command GPGCMD instead of gpg.

--gpg-args ARGS
     Pass the specified options to gpg.

--tar TARCMD
     Use the specified command TARCMD instead of tar.

--tar-args ARGS
     Pass the specified options to tar.

--version
     Print version of the program and exit.

--help
     Display a brief help page and exit.

diagnostics

The program returns 0 if everything was fine, 1 otherwise.

examples

Some examples:

Encrypt the contents of directory mydocs for user Bob to file test1:

     gpg-zip --encrypt --output test1 --gpg-args  -r Bob mydocs

List the contents of archive test1:

     gpg-zip --list-archive test1

see also
     [file see-also-note.texi not included]