Using gpg (1.x) with gpg-agent (v2.x)

If one needs to sign/encrypt multiplies files and the PGP key is encrypted, they can use the gpg-agent to keep the key accessible for some period of time and enter the password once. For compatibility reasons I need to use gpgv1 but the `gpg-agent` which come with Fedora is from v2 package, and there seems to be some problem with that, as the v2 agent dose not export the environment variables which the v1 client expecting for.

And when trying to use it you’ll get this message

gpg: gpg-agent is not available in this session

Running gpg-agent --daemon and then looking on the files which the agent open with lsof -p $(pidof gpg-agent) revile where are the socket files

$ lsof -p $(pidof gpg-agent)
...
gpg-agent 17640 rabin    3u     unix 0x000000009074bd36       0t0 5289807 /run/user/1000/gnupg/S.gpg-agent type=STREAM
gpg-agent 17640 rabin    4u     unix 0x00000000ebaf0e30       0t0 5289809 /run/user/1000/gnupg/S.gpg-agent.extra type=STREAM
gpg-agent 17640 rabin    5u     unix 0x00000000b967d2d6       0t0 5289811 /run/user/1000/gnupg/S.gpg-agent.browser type=STREAM
gpg-agent 17640 rabin    6u     unix 0x000000008c579ff3       0t0 5289813 /run/user/1000/gnupg/S.gpg-agent.ssh type=STREAM
...

and so by exporting the new path with

export GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1

solved my problem.

Resources

  • https://lists.gnupg.org/pipermail/gnupg-devel/2014-October/029024.html
  • https://unix.stackexchange.com/questions/231386/how-to-make-gpg-find-gpg-agent

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *