-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gpg-agent user services do not work anymore, making it unusable as a ssh-agent #213794
Comments
Can you be more specific? If you mean this is an issue on 22.11 I can't reproduce it, I don't know about unstable.
Yes, that's the most annoying issue with gpg-agent. As far as I know, there is no system-wide configuration file, so the user service was necessary to set the pinentry program.
Well, I would have gone the other way around: deprecating the automatic starting of the agent that has been a constant source of pain, but go figure. So, I guess we have implement the services and socket in NixOS, or maybe we could use |
I have set up a branch using gpgconf here and it seems to be working, so far. I should write a NixOS test to be sure, though. |
You cannot use the gpg agent with ssh support and the normal ssh agent. Also are you changing the gpg home directory (
Yes, this is expected. |
I am confused. Is this issue about a problem you have or about the upcoming change? |
This issue is about the NixOS module for gnupg with NixOS version 22.11
correct, the ssh-agent provided by ssh itself is dsiabled (
no, this is just left at the default values
I agree, daemons and agents should be mainly configured by the distro, but well, the gnupg project does it this way.
I'll give it a try. I don't like how it will cause files in the $GPGHOME and thus the users home-directory to be written though. My system is working currently, because I moved my gpg config to home-manager, for which this approach works fine, but NixOS itself having to write config files into the users home directory does not seem right. home-manager specific details
home manager also ships the deprecated user services, but that's not what makes it work. It works by magic of home.sessionVariablesExtra = optionalString cfg.enableSshSupport ''
if [[ -z "$SSH_AUTH_SOCK" ]]; then
export SSH_AUTH_SOCK="$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"
fi
''; and thus causing the gpg-agent to be started during shell initialization with the following output if the agent is not yet running
|
FYI any updates or fixes will likely not be backported unless they are pretty severe and have a low chance to introduce other breaking changes.
I have reached out to upstream about the change that they removed the systemd files and we are exploring the options but we don't have to many because upstream is missing some options we would like.
We usually don't do this and I think we still have better options here. |
It's rare but non unheard of, for example the syncthing module does exactly this.
What are you thinking? Anyway, I wrote a pretty comprehensive test for gnupg and openssh. You should find it useful for experimenting. |
Ancient issue but it could probably be closed, unless OP still has issues. I havent seen/had any issues in the last many months of using gpg-ssh-agent |
I don't think it's relevant anymore: we now have our own systemd units in nixpkgs, use the system-wide configuration to set up pinentry program (so even if gnupg autostarts the agent it will work) and I've never seen that error about |
Describe the bug
gpg-agent stopped working recently. The systemd user service that is supposed to exist if
programs.gnupg.agent.enable = true;
fails to start. This does not seem to be relavant for most gpg actions, since it will autostart the agent if needed (albeit possibly missing the pinentry program configuration?), but it breaks usage of gpg-agent as ssh-agent.Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
gpg-agent systemd user service starts sucessfully. SSH can use it as an ssh-agent.
Additional context
The missing gpg-agent does not seem to be relevant for performing gpg tasks, since it get's autostarted by gpg when needed. But for using it as an ssh-agent this does not happen.
Upstream has removed the example systemd user units in https://dev.gnupg.org/rGeae28f1bd4a5632e8f8e85b7248d1c4d4a10a5ed , the related ticket https://dev.gnupg.org/T6336 gives some background information:
I'm not sure if this applies here at all. My interpretation is that abovementioned race condition is relevant if the systemd user unit is socket activated. If it is started on login gpg should detect the already running agent reliably and not start another one, so that should be fine.
I read https://github.com/NixOS/nixpkgs/blob/1c02dbee4726f9cde21cd103cc1e56dd2b20d72e/nixos/modules/programs/gnupg.nix#L47#L50 as "with ssh support the service is started on login, without it it's socket activated", but I did not find the corresponding implementation. I guess it's actually still socket-activated, but since https://github.com/NixOS/nixpkgs/blob/1c02dbee4726f9cde21cd103cc1e56dd2b20d72e/nixos/modules/programs/gnupg.nix#L141#L145 configures
environment.extraInit
causing gpg to be used very early in a session and the agent is then setup.I don't know what the correct solution is, since upstream discourages using the systemd user units and I just want my gpg as ssh-agent back.
Notify maintainers
@fpletz @vrthra @mrcjkb @rnhmjoj @SuperSandro2000 @pennae
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.The text was updated successfully, but these errors were encountered: