.\" Created from Texinfo source by yat2m 1.47 .TH GPG-CONNECT-AGENT 1 2024-03-04 "GnuPG 2.4.5" "GNU Privacy Guard 2.4" .SH NAME .B gpg-connect-agent \- Communicate with a running agent .SH SYNOPSIS .B gpg-connect-agent .RI [ options ] [commands] .SH DESCRIPTION The \fBgpg-connect-agent\fR is a utility to communicate with a running \fBgpg-agent\fR. It is useful to check out the commands \fBgpg-agent\fR 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 \fBgpg-agent\fR in server mode; but here we connect to a running instance. The following options may be used: .TP .B --dirmngr Connect to a running directory manager (keyserver client) instead of to the gpg-agent. If a dirmngr is not running, start it. .TP .B --keyboxd Connect to a running keybox daemon instead of to the gpg-agent. If a keyboxd is not running, start it. .TP .B -S .TQ .B --raw-socket \fIname\fR Connect to socket \fIname\fR 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. .TP .B -E .TQ .B --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 \fBgpgsm\fR: .RS 2 .nf gpg-connect-agent --exec gpgsm --server .fi .RE Note that you may not use options on the command line in this case. .TP .B -v .TQ .B --verbose Output additional information while running. .TP .B -q .TP .B --quiet Try to be as quiet as possible. .TP .B --homedir \fIdir\fR Set the name of the home directory to \fIdir\fR. If this option is not used, the home directory defaults to \(oq\fI~/.gnupg\fR\(cq. It is only recognized when given on the command line. It also overrides any home directory stated through the environment variable \(oq\fIGNUPGHOME\fR\(cq or (on Windows systems) by means of the Registry entry \fIHKCU\\Software\\GNU\\GnuPG:HomeDir\fR. On Windows systems it is possible to install GnuPG as a portable application. In this case only this command line option is considered, all other ways to set a home directory are ignored. .TP .B --chuid \fIuid\fR Change the current user to \fIuid\fR which may either be a number or a name. This can be used from the root account to run gpg-connect-agent for another user. If \fIuid\fR is not the current UID a standard PATH is set and the envvar GNUPGHOME is unset. To override the latter the option \fB--homedir\fR can be used. This option has only an effect when used on the command line. This option has currently no effect at all on Windows. .TP .B --no-ext-connect When using \fB-S\fR or \fB--exec\fR, \fBgpg-connect-agent\fR connects to the Assuan server in extended mode to allow descriptor passing. This option makes it use the old mode. .TP .B --no-autostart Do not start the gpg-agent or the dirmngr if it has not yet been started. .TP .B --no-history In interactive mode the command line history is usually saved and restored to and from a file below the GnuPG home directory. This option inhibits the use of that file. .TP .B --agent-program \fIfile\fR Specify the agent program to be started if none is running. The default value is determined by running \fBgpgconf\fR with the option \fB--list-dirs\fR. Note that the pipe symbol (\fB|\fR) is used for a regression test suite hack and may thus not be used in the file name. .TP .B --dirmngr-program \fIfile\fR 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 \fB--dirmngr\fR. .TP .B --keyboxd-program \fIfile\fR Specify the keybox daemon program to be started if none is running. This has only an effect if used together with the option \fB--keyboxd\fR. .TP .B -r \fIfile\fR .TQ .B --run \fIfile\fR Run the commands from \fIfile\fR at startup and then continue with the regular input method. Note, that commands given on the command line are executed after this file. .TP .B -s .TQ .B --subst Run the command \fB/subst\fR at startup. .TP .B --hex Print data lines in a hex format and the ASCII representation of non-control characters. .TP .B --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. .TP .B -u .TQ .B --unbuffered Set stdin and stdout into unbuffered I/O mode. This this sometimes useful for scripting. .P .SH 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 (\fB/\fR). .TP .B /echo \fIargs\fR Just print \fIargs\fR. .TP .B /let \fIname\fR \fIvalue\fR Set the variable \fIname\fR to \fIvalue\fR. Variables are only substituted on the input if the \fB/subst\fR 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: .RS .TP .B get Return a value described by the argument. Available arguments are: .RS .TP .B cwd The current working directory. .TP .B homedir The gnupg homedir. .TP .B sysconfdir GnuPG's system configuration directory. .TP .B bindir GnuPG's binary directory. .TP .B libdir GnuPG's library directory. .TP .B libexecdir GnuPG's library directory for executable files. .TP .B datadir GnuPG's data directory. .TP .B serverpid The PID of the current server. Command \fB/serverpid\fR must have been given to return a useful value. .RE .TP .B unescape \fIargs\fR Remove C-style escapes from \fIargs\fR. Note that \fB\\0\fR and \fB\\x00\fR terminate the returned string implicitly. The string to be converted are the entire arguments right behind the delimiting space of the function name. .TP .B unpercent \fIargs\fR .TQ .B unpercent+ \fIargs\fR Remove percent style escaping from \fIargs\fR. Note that \fB%00\fR terminates the string implicitly. The string to be converted are the entire arguments right behind the delimiting space of the function name. \fBunpercent+\fR also maps plus signs to a spaces. .TP .B percent \fIargs\fR .TQ .B percent+ \fIargs\fR Escape the \fIargs\fR using percent style escaping. Tabs, formfeeds, linefeeds, carriage returns and colons are escaped. \fBpercent+\fR also maps spaces to plus signs. .TP .B errcode \fIarg\fR .TQ .B errsource \fIarg\fR .TQ .B errstring \fIarg\fR Assume \fIarg\fR is an integer and evaluate it using \fBstrtol\fR. Return the gpg-error error code, error source or a formatted string with the error code and error source. .TP .B + .TQ .B - .TQ .B * .TQ .B / .TQ .B % Evaluate all arguments as long integers using \fBstrtol\fR and apply this operator. A division by zero yields an empty string. .TP .B ! .TQ .B | .TQ .B & Evaluate all arguments as long integers using \fBstrtol\fR and apply the logical operators NOT, OR or AND. The NOT operator works on the last argument only. .RE .TP .B /definq \fIname\fR \fIvar\fR Use content of the variable \fIvar\fR for inquiries with \fIname\fR. \fIname\fR may be an asterisk (\fB*\fR) to match any inquiry. .TP .B /definqfile \fIname\fR \fIfile\fR Use content of \fIfile\fR for inquiries with \fIname\fR. \fIname\fR may be an asterisk (\fB*\fR) to match any inquiry. .TP .B /definqprog \fIname\fR \fIprog\fR Run \fIprog\fR for inquiries matching \fIname\fR and pass the entire line to it as command line arguments. .TP .B /datafile \fIname\fR Write all data lines from the server to the file \fIname\fR. 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 \fIname\fR 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. .TP .B /showdef Print all definitions .TP .B /cleardef Delete all definitions .TP .B /sendfd \fIfile\fR \fImode\fR Open \fIfile\fR in \fImode\fR (which needs to be a valid \fBfopen\fR mode string) and send the file descriptor to the server. This is usually followed by a command like \fBINPUT FD\fR to set the input source for other commands. .TP .B /recvfd Not yet implemented. .TP .B /open \fIvar\fR \fIfile\fR [\fImode\fR] Open \fIfile\fR and assign the file descriptor to \fIvar\fR. Warning: This command is experimental and might change in future versions. .TP .B /close \fIfd\fR Close the file descriptor \fIfd\fR. Warning: This command is experimental and might change in future versions. .TP .B /showopen Show a list of open files. .TP .B /serverpid Send the Assuan command \fBGETINFO pid\fR to the server and store the returned PID for internal purposes. .TP .B /sleep Sleep for a second. .TP .B /hex .TQ .B /nohex Same as the command line option \fB--hex\fR. .TP .B /decode .TQ .B /nodecode Same as the command line option \fB--decode\fR. .TP .B /subst .TQ .B /nosubst Enable and disable variable substitution. It defaults to disabled unless the command line option \fB--subst\fR has been used. If /subst as been enabled once, leading whitespace is removed from input lines which makes scripts easier to read. .TP .B /while \fIcondition\fR .TQ .B /end These commands provide a way for executing loops. All lines between the \fBwhile\fR and the corresponding \fBend\fR are executed as long as the evaluation of \fIcondition\fR yields a non-zero value or is the string \fBtrue\fR or \fByes\fR. The evaluation is done by passing \fIcondition\fR to the \fBstrtol\fR function. Example: .RS 2 .nf /subst /let i 3 /while $i /echo loop counter is $i /let i ${- $i 1} /end .fi .RE .TP .B /if \fIcondition\fR .TQ .B /end These commands provide a way for conditional execution. All lines between the \fBif\fR and the corresponding \fBend\fR are executed only if the evaluation of \fIcondition\fR yields a non-zero value or is the string \fBtrue\fR or \fByes\fR. The evaluation is done by passing \fIcondition\fR to the \fBstrtol\fR function. .TP .B /run \fIfile\fR Run commands from \fIfile\fR. .TP .B /history --clear Clear the command history. .TP .B /bye Terminate the connection and the program. .TP .B /help Print a list of available control commands. .P .SH SEE ALSO \fBgpg-agent\fR(1), \fBscdaemon\fR(1) The full documentation for this tool is maintained as a Texinfo manual. If GnuPG and the info program are properly installed at your site, the command .RS 2 .nf info gnupg .fi .RE should give you access to the complete manual including a menu structure and an index.