all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@retrospec.tv>
To: 72248@debbugs.gnu.org
Subject: bug#72248: home-gpg-agent `ssh-support?' breaks SSH agent forwarding
Date: Mon, 22 Jul 2024 19:13:44 -0700	[thread overview]
Message-ID: <87h6cgu7io.fsf@meson> (raw)

I have a fairly standard agent setup for using a hardware token 
for SSH and GPG.

On my local (Debian, currently) machine, gpg-agent’s configuration 
has `enable-ssh-support', and my shell dotfiles set SSH_AUTH_SOCK 
to the gpg-agent socket, which allows SSH to access the 
authentication key on my token.  Additionally, my SSH config has 
`ForwardAgent yes', which allows the remote system to talk to the 
local gpg-agent, enabling things like logging into a remote 
machine and running `git pull' for repos accessed over SSH.

For this to work requires /conditionally/ setting SSH_AUTH_SOCK: 
on the local host, it needs to be set to the local GPG agent; but 
on a remote host, it needs to be the forwarded SSH agent.  The 
SSH_AUTH_SOCK variable is set by SSH when setting up the 
connection, so all that’s needed is to check $SSH_CONNECTION, and 
leave SSH_AUTH_SOCK untouched -- this is what my shell dotfiles 
do.

Unfortunately, this breaks when logging into a remote system which 
uses Guix Home’s `home-gpg-agent-service-type'.  I initially 
thought this was an issue converting my homegrown dotfile setup to 
Guix Home, but after troubleshooting, this appears to be a Guix 
Home bug.  Specifically, the issue is the 
`home-gpg-agent-environment-variables' procedure in (gnu home 
services gnupg), which, if `ssh-support?' is enabled in 
home-gpg-agent-configuration, *unconditionally* sets SSH_AUTH_SOCK 
to the GPG agent socket.  This works for the local host -- I can 
log into remote systems from a Guix Home machine -- but breaks 
when SSH’ing to a remote system using Guix Home.

I’m not sure how to fix this; home-gpg-agent-environment-variables 
returns a list of variables to set, with no facility for 
conditional logic.  Use of bash config files would break for 
anyone using a different shell -- and how would 
`home-gpg-agent-service-type' know what shell the user has chosen?

If I unset `ssh-support?', it disables both the bad behavior, but 
also the gpg-agent configuration which enables SSH agent support.

Right now, the only thing that seems like it might work is adding 
another home-environment-variables-service-type which saves the 
value of SSH_AUTH_SOCK to another variable, which my shell init 
files can look at later in the process.  This feels like a 
graceless hack (and the base stuff to make this all work already 
feels overly complex), and would require further hackery for the 
same dotfiles to work on non-Guix Home systems, which at least 
some of my configs still do.

The other option is to quit using `home-gpg-agent-service-type' at 
all, and handle all this stuff manually.  I don’t love it, but it 
seems like probably the best option.

Thoughts?

Thanks,

  — Ian




                 reply	other threads:[~2024-07-23  3:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6cgu7io.fsf@meson \
    --to=ian@retrospec.tv \
    --cc=72248@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.