How to make remote gpg talk to specific Unix socket (for forwarded local gpg-agent)

Troy list-gnupg at reml.org
Mon Jan 16 16:56:58 CET 2023


Hi,

I was wondering if you could give me a pointer.

I'm ssh'ing to a machine where I'm trying to run gpg, which I hope to 
talk to the gpg-agent that's running on my local laptop, forwarded 
through ssh.
I'm following the instructions at https://wiki.gnupg.org/AgentForwarding 
but I don't know how to make gpg use a specific Unix socket to 
communicate with my forwarded gpg-agent.

The problem is that there's already a gpg-agent running at the remote (I 
think started by systemd or the X server), which I don't want to 
disturb.  For my ssh connection, I try to create a new Unix domain 
socket by using
     ssh -R 
/run/user/1000/gnupg/S.gpg-agent.remote:/Users/troy/.gnupg/S.gpg-agent.extra 
-o StreamLocalBindUnlink=yes -o ExitOnForwardFailure=yes

But then how do I make gpg use/run/user/1000/gnupg/S.gpg-agent.remote .  
It seems that gpg uses gpgconf to figure out that path. And there's no 
flag or envvar that I can use to override that (anymore).

The only thing I can think of is to specify a new --homedir so that the 
socket is created elsewhere, and then I'd have to change the port 
forwarding to reflect the dynamically-generated path which will look 
something like /run/user/1000/gnupg/d.xhmoxiusfxtwuy8s69hkyxtc .  So 
either I have to do two separate ssh calls or I have to use an expect 
script to automate the addition of port forwarding on an existing 
session.  Plus, now the homedir is different and all my files are in the 
wrong place.

I hope I'm missing something obvious.  Thanks for any ideas.

I'm using:
- Ubuntu 22.04.1 LTS
- gpg (GnuPG) 2.2.27
- OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022

Troy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20230116/2a4aedfc/attachment.html>


More information about the Gnupg-users mailing list