{
    "mode": "man",
    "parameter": "gpg-connect-agent",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/gpg-connect-agent/1/json",
    "generated": "2026-06-16T06:28:37Z",
    "synopsis": "gpg-connect-agent [options][commands]",
    "sections": {
        "NAME": {
            "content": "gpg-connect-agent - Communicate with a running agent\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "gpg-connect-agent [options][commands]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  gpg-connect-agent is a utility to communicate with a running gpg-agent.  It is useful to\ncheck out the commands gpg-agent provides using the Assuan interface.  It might also be  use‐\nful for scripting simple applications.  Input is expected at stdin and output gets printed to\nstdout.\n\nIt is very similar to running gpg-agent in server mode; but here we connect to a running  in‐\nstance.\n\n\n\n\nThe following options may be used:\n\n",
            "subsections": [
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "--verbose",
                    "content": "Output additional information while running.\n\n",
                    "long": "--verbose"
                },
                {
                    "name": "-q",
                    "content": "",
                    "flag": "-q"
                },
                {
                    "name": "--quiet",
                    "content": "Try to be as quiet as possible.\n\n\n--homedir dir\nSet the name of the home directory to dir. If this option is not used, the home direc‐\ntory defaults to ‘~/.gnupg’.  It is only recognized when given on  the  command  line.\nIt  also  overrides  any  home  directory  stated  through  the  environment  variable\n‘GNUPGHOME’ or (on  Windows  systems)  by  means  of  the  Registry  entry  HKCU\\Soft‐\nware\\GNU\\GnuPG:HomeDir.\n\nOn Windows systems it is possible to install GnuPG as a portable application.  In this\ncase only this command line option is considered, all other ways to set a home  direc‐\ntory are ignored.\n\nTo  install  GnuPG as a portable application under Windows, create an empty file named\n‘gpgconf.ctl’ in the same directory as the tool ‘gpgconf.exe’.  The root  of  the  in‐\nstallation  is  then  that directory; or, if ‘gpgconf.exe’ has been installed directly\nbelow a directory named ‘bin’, its parent directory.  You also need to make sure  that\nthe  following  directories exist and are writable: ‘ROOT/home’ for the GnuPG home and\n‘ROOT/var/cache/gnupg’ for internal cache files.\n\n\n--agent-program file\nSpecify the agent program to be started if none is running.  The default value is  de‐\ntermined  by  running  gpgconf with the option --list-dirs.  Note that the pipe symbol\n(|) is used for a regression test suite hack and may thus not  be  used  in  the  file\nname.\n\n\n--dirmngr-program file\nSpecify the directory manager (keyserver client) program to be started if none is run‐\nning.  This has only an effect if used together with the option --dirmngr.\n\n",
                    "long": "--quiet"
                },
                {
                    "name": "--dirmngr",
                    "content": "Connect to a running directory manager (keyserver client) instead of to the gpg-agent.\nIf a dirmngr is not running, start it.\n\n",
                    "long": "--dirmngr"
                },
                {
                    "name": "-S",
                    "content": "--raw-socket name\nConnect  to  socket name assuming this is an Assuan style server.  Do not run any spe‐\ncial initializations or environment checks.  This may be used to directly  connect  to\nany Assuan style socket server.\n\n",
                    "flag": "-S"
                },
                {
                    "name": "-E",
                    "content": "--exec Take the rest of the command line as a program and it's arguments and execute it as an\nAssuan server. Here is how you would run gpgsm:\ngpg-connect-agent --exec gpgsm --server\nNote that you may not use options on the command line in this case.\n\n",
                    "flag": "-E"
                },
                {
                    "name": "--no-ext-connect",
                    "content": "When using -S or --exec, gpg-connect-agent connects to the Assuan server  in  extended\nmode to allow descriptor passing.  This option makes it use the old mode.\n\n",
                    "long": "--no-ext-connect"
                },
                {
                    "name": "--no-autostart",
                    "content": "Do not start the gpg-agent or the dirmngr if it has not yet been started.\n\n",
                    "long": "--no-autostart"
                },
                {
                    "name": "-r",
                    "content": "--run file\nRun the commands from file at startup and then continue with the regular input method.\nNote, that commands given on the command line are executed after this file.\n\n",
                    "flag": "-r"
                },
                {
                    "name": "-s",
                    "content": "",
                    "flag": "-s"
                },
                {
                    "name": "--subst",
                    "content": "Run the command /subst at startup.\n\n\n--hex  Print data lines in a hex format and the ASCII representation of  non-control  charac‐\nters.\n\n",
                    "long": "--subst"
                },
                {
                    "name": "--decode",
                    "content": "Decode  data  lines.   That is to remove percent escapes but make sure that a new line\nalways starts with a D and a space.\n\n",
                    "long": "--decode"
                }
            ]
        },
        "CONTROL COMMANDS": {
            "content": "While reading Assuan commands, gpg-agent also allows a few special commands  to  control  its\noperation.  These control commands all start with a slash (/).\n\n\n\n/echo args\nJust print args.\n\n\n/let name value\nSet  the  variable  name to value.  Variables are only substituted on the input if the\n/subst has been used.  Variables are referenced by prefixing the name  with  a  dollar\nsign  and optionally include the name in curly braces.  The rules for a valid name are\nidentically to those of the standard bourne shell.  This is not yet enforced  but  may\nbe  in  the future.  When used with curly braces no leading or trailing white space is\nallowed.\n\nIf a variable is not found, it is searched in the environment and if found  copied  to\nthe table of variables.\n\nVariable  functions  are  available:  The  name of the function must be followed by at\nleast one space and the at least one argument.  The following functions are available:\n\n\nget    Return a value described by the argument.  Available arguments are:\n\n\ncwd    The current working directory.\n\nhomedir\nThe gnupg homedir.\n\nsysconfdir\nGnuPG's system configuration directory.\n\nbindir GnuPG's binary directory.\n\nlibdir GnuPG's library directory.\n\nlibexecdir\nGnuPG's library directory for executable files.\n\ndatadir\nGnuPG's data directory.\n\nserverpid\nThe PID of the current server. Command /serverpid must have  been  given\nto return a useful value.\n\n\nunescape args\nRemove C-style escapes from args.  Note that \\0 and \\x00 terminate the returned\nstring implicitly.  The string to be converted are the entire  arguments  right\nbehind the delimiting space of the function name.\n\n\nunpercent args\nunpercent+ args\nRemove  percent  style escaping from args.  Note that %00 terminates the string\nimplicitly.  The string to be converted are the entire arguments  right  behind\nthe delimiting space of the function name. unpercent+ also maps plus signs to a\nspaces.\n\n\npercent args\npercent+ args\nEscape the args using percent style escaping.  Tabs, formfeeds, linefeeds, car‐\nriage returns and colons are escaped. percent+ also maps spaces to plus signs.\n\n\nerrcode arg\nerrsource arg\nerrstring arg\nAssume  arg  is  an integer and evaluate it using strtol.  Return the gpg-error\nerror code, error source or a formatted string with the error  code  and  error\nsource.\n\n\n\n+\n-\n*\n/\n%      Evaluate  all  arguments as long integers using strtol and apply this operator.\nA division by zero yields an empty string.\n\n\n!\n|\n&      Evaluate all arguments as long integers using strtol and apply the logical  op‐\nerators NOT, OR or AND.  The NOT operator works on the last argument only.\n\n\n\n\n\n/definq name var\nUse  content of the variable var for inquiries with name.  name may be an asterisk (*)\nto match any inquiry.\n\n\n\n/definqfile name file\nUse content of file for inquiries with name.  name may be an asterisk (*) to match any\ninquiry.\n\n\n/definqprog name prog\nRun  prog  for  inquiries matching name and pass the entire line to it as command line\narguments.\n\n\n/datafile name\nWrite all data lines from the server to the file name.  The file is opened for writing\nand  created  if  it  does not exists.  An existing file is first truncated to 0.  The\ndata written to the file fully decoded.  Using a single dash for name writes  to  std‐\nout.  The file is kept open until a new file is set using this command or this command\nis used without an argument.\n\n",
            "subsections": [
                {
                    "name": "/showdef",
                    "content": "Print all definitions\n\n"
                },
                {
                    "name": "/cleardef",
                    "content": "Delete all definitions\n\n\n/sendfd file mode\nOpen file in mode (which needs to be a valid fopen mode string) and send the file  de‐\nscriptor  to  the  server.  This is usually followed by a command like INPUT FD to set\nthe input source for other commands.\n\n"
                },
                {
                    "name": "/recvfd",
                    "content": "Not yet implemented.\n\n\n/open var file [mode]\nOpen file and assign the file descriptor to var.  Warning: This command is  experimen‐\ntal and might change in future versions.\n\n\n/close fd\nClose  the file descriptor fd.  Warning: This command is experimental and might change\nin future versions.\n\n"
                },
                {
                    "name": "/showopen",
                    "content": "Show a list of open files.\n\n"
                },
                {
                    "name": "/serverpid",
                    "content": "Send the Assuan command GETINFO pid to the server and store the returned PID  for  in‐\nternal purposes.\n\n\n/sleep Sleep for a second.\n\n"
                },
                {
                    "name": "/hex",
                    "content": "/nohex Same as the command line option --hex.\n\n"
                },
                {
                    "name": "/decode",
                    "content": ""
                },
                {
                    "name": "/nodecode",
                    "content": "Same as the command line option --decode.\n\n"
                },
                {
                    "name": "/subst",
                    "content": ""
                },
                {
                    "name": "/nosubst",
                    "content": "Enable  and disable variable substitution.  It defaults to disabled unless the command\nline option --subst has been used.  If /subst as been enabled once, leading whitespace\nis removed from input lines which makes scripts easier to read.\n\n\n/while condition\n/end   These commands provide a way for executing loops.  All lines between the while and the\ncorresponding end are executed as long as the evaluation of condition  yields  a  non-\nzero  value or is the string true or yes.  The evaluation is done by passing condition\nto the strtol function.  Example:\n\n/subst\n/let i 3\n/while $i\n/echo loop counter is $i\n/let i ${- $i 1}\n/end\n\n\n/if condition\n/end   These commands provide a way for conditional execution.  All lines between the if  and\nthe  corresponding  end are executed only if the evaluation of condition yields a non-\nzero value or is the string true or yes.  The evaluation is done by passing  condition\nto the strtol function.\n\n\n/run file\nRun commands from file.\n\n\n/bye   Terminate the connection and the program.\n\n\n/help  Print a list of available control commands.\n\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "gpg-agent(1), scdaemon(1)\n\nThe  full  documentation  for  this tool is maintained as a Texinfo manual.  If GnuPG and the\ninfo program are properly installed at your site, the command\n\ninfo gnupg\n\nshould give you access to the complete manual including a menu structure and an index.\n\n\n\n\n\nGnuPG 2.2.27                                 2020-12-21                         GPG-CONNECT-AGENT(1)",
            "subsections": []
        }
    },
    "summary": "gpg-connect-agent - Communicate with a running agent",
    "flags": [
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--verbose",
            "arg": null,
            "description": "Output additional information while running."
        },
        {
            "flag": "-q",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--quiet",
            "arg": null,
            "description": "Try to be as quiet as possible. --homedir dir Set the name of the home directory to dir. If this option is not used, the home direc‐ tory defaults to ‘~/.gnupg’. It is only recognized when given on the command line. It also overrides any home directory stated through the environment variable ‘GNUPGHOME’ or (on Windows systems) by means of the Registry entry HKCU\\Soft‐ ware\\GNU\\GnuPG:HomeDir. 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 direc‐ tory are ignored. To install GnuPG as a portable application under Windows, create an empty file named ‘gpgconf.ctl’ in the same directory as the tool ‘gpgconf.exe’. The root of the in‐ stallation is then that directory; or, if ‘gpgconf.exe’ has been installed directly below a directory named ‘bin’, its parent directory. You also need to make sure that the following directories exist and are writable: ‘ROOT/home’ for the GnuPG home and ‘ROOT/var/cache/gnupg’ for internal cache files. --agent-program file Specify the agent program to be started if none is running. The default value is de‐ termined 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 run‐ ning. This has only an effect if used together with the option --dirmngr."
        },
        {
            "flag": "",
            "long": "--dirmngr",
            "arg": null,
            "description": "Connect to a running directory manager (keyserver client) instead of to the gpg-agent. If a dirmngr is not running, start it."
        },
        {
            "flag": "-S",
            "long": null,
            "arg": null,
            "description": "--raw-socket name Connect to socket name assuming this is an Assuan style server. Do not run any spe‐ cial initializations or environment checks. This may be used to directly connect to any Assuan style socket server."
        },
        {
            "flag": "-E",
            "long": null,
            "arg": null,
            "description": "--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."
        },
        {
            "flag": "",
            "long": "--no-ext-connect",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": "--no-autostart",
            "arg": null,
            "description": "Do not start the gpg-agent or the dirmngr if it has not yet been started."
        },
        {
            "flag": "-r",
            "long": null,
            "arg": null,
            "description": "--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."
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--subst",
            "arg": null,
            "description": "Run the command /subst at startup. --hex Print data lines in a hex format and the ASCII representation of non-control charac‐ ters."
        },
        {
            "flag": "",
            "long": "--decode",
            "arg": null,
            "description": "Decode data lines. That is to remove percent escapes but make sure that a new line always starts with a D and a space."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "gpg-agent",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/gpg-agent/1/json"
        },
        {
            "name": "scdaemon",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/scdaemon/1/json"
        },
        {
            "name": "GPG-CONNECT-AGENT",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/GPG-CONNECT-AGENT/1/json"
        }
    ]
}