7

Trying to configure gpg in a way that I enter passphrase only once, and it will work for the whole session.

However, this is what I'm getting:

$ pgrep gpg-agent | wc 
      0       0       0

$ gpg-agent --daemon
gpg-agent: a gpg-agent is already running - not starting a new one

$ pgrep gpg-agent
26401

I.e., gpg-agent --daemon will start a gpg-agent but forgot it has started one right afterward, and blocks itself. Tried many times after gpgconf --kill gpg-agent, or

kill `pgrep gpg-agent`

and the results are always the same.

What's wrong?

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

installed packages with KW of gpg:

gpg_2.2.4-1ubuntu1.2 gpg-agent_2.2.4-1ubuntu1.2 gpg-wks-client_2.2.4-1ubuntu1.2 gpg-wks-server_2.2.4-1ubuntu1.2 gpgconf_2.2.4-1ubuntu1.2 gpgsm_2.2.4-1ubuntu1.2 gpgv_2.2.4-1ubuntu1.2

Benjamin Loison
  • 183
  • 1
  • 6
xpt
  • 9,385
  • 44
  • 120
  • 178

1 Answers1

4

I had the same problem. I think your agent starts somewhat correctly but does not set $SSH_AUTH_SOCK for ssh to find the agent. gpgconf --list-dirs agent-ssh-socket gives you the location of the socket. Depending of your os it could be ~/.gnupg/S.gpg-agent.ssh or /run/user/6666/gnupg/S.gpg-agent.ssh. You can set it with SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)".

You can add the following lines to your .bashrc/.zshrc to start the agent:

eval $(gpg-connect-agent --quiet /bye)
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

I hope it helps.

Benjamin Loison
  • 183
  • 1
  • 6