On Unix platforms the OpenSSH Agent protocol is always enabled, but gpg-agent will only set the SSH_AUTH_SOCK variable if the option enable-ssh-support is given. Some Linux distributions use the presence of this option to decide whether the old ssh-agent shall be started.
On Windows support for the native ssh implementation must be enabled using the the option enable-win32-openssh-support. For using gpg-agent as a replacement for PuTTY's Pageant, the option enable-putty-support must be enabled.
In this mode of operation, the agent does not only implement the gpg-agent protocol, but also the agent protocol used by OpenSSH (through a separate socket or via Named Pipes) or the protocol used by PuTTY. Consequently, this allows one to use the gpg-agent as a drop-in replacement for the ssh-agent.
SSH keys, which are to be used through the agent, need to be added to the gpg-agent initially through the ssh-add utility. When a key is added, ssh-add will ask for the password of the provided key file and send the unprotected key material to the agent; this causes the gpg-agent to ask for a passphrase, which is to be used for encrypting the newly received key and storing it in a gpg-agent specific directory.
Once a key has been added to the gpg-agent this way, the gpg-agent will be ready to use the key.
Note: in case the gpg-agent receives a signature request, the user might need to be prompted for a passphrase, which is necessary for decrypting the stored key. Since the ssh-agent protocol does not contain a mechanism for telling the agent on which display/terminal it is running, gpg-agent's ssh-support will use the TTY or X display where gpg-agent has been started. To switch this display to the current one, the following command may be used:
gpg-connect-agent updatestartuptty /bye
Although all GnuPG components try to start the gpg-agent as needed, this is not possible for the ssh support because ssh does not know about it. Thus if no GnuPG tool which accesses the agent has been run, there is no guarantee that ssh is able to use gpg-agent for authentication. To fix this you may start gpg-agent if needed using this simple command:
Adding the --verbose shows the progress of starting the agent.
The --enable-putty-support is only available under Windows and allows the use of gpg-agent with the ssh implementation putty. This is similar to the regular ssh-agent support but makes use of Windows message queue as required by putty.
The order in which keys are presented to ssh are:
- Negative Use-for-ssh values
-
If a key file has the attribute "Use-for-ssh" and its value is
negative, these keys are presented first to ssh. The negative
values are capped at -999 with -999 being lower ranked than -1.
These values can be used to prefer on-disk keys over keys taken
from active cards.
- Active cards
-
Active cards (inserted into a card reader or plugged in tokens)
are always tried; they are ordered by their serial numbers.
- Keys listed in the sshcontrol file
-
Non-disabled keys from the sshcontrol file are presented in the
order they appear in this file. Note that the sshcontrol file
is deprecated.
- Positive Use-for-ssh values
-
If a key file has the attribute "Use-for-ssh" and its value is
"yes", "true", or any positive number the key is presented in
the order of their values. "yes" and "true" have a value of 1;
other values are capped at 99999.
Editing the "Use-for-ssh" values can be done with an editor or using gpg-connect-agent and "KEYATTR" (Remember to append a colon to the key; i.e. use "Use-for-ssh:").