6

I'm using Fedora 24 (amd64), which is running GNOME 3/GNOME Shell as a desktop environment, using Wayland as the display server, and SystemD as the init. Pretty standard, out of the box, this is the way Fedora 24 ships.

My previous distribution was still using X, so I had a script called 90-gpg-agent in /etc/X11/Xsession.d/autostart which conditionally started gpg-agent or sourced its exported variables, making them available to graphical programs that started. This made it so that programs like unison-gtk would have the correct SSH_AUTH_SOCK environment variable so they could use gpg-agent as the SSH agent. Anything running inside a bash session would just use the environment variables in my .bashrc, but graphical applications needed this to be exported for access.

Is there an equivalent for Wayland/GNOME/SystemD which will export these environment variables and provide them to applications starting in that display server+desktop environment?

5

Try using systemctl --user import-environment SSH_AUTH_SOCK in a script in /etc/X11/xinit/xinitrc.d/. Check out /etc/X11/xinit/xinitrc.d/50-systemd-user.sh for reference.

1

Simply enable ssh support in your gpg agent – add the line enable-ssh-agent to ~/.gnupg/gpg-agent.conf – and log out (and back in).

This setting is picked up by /etc/X11/Xsession.d/90gpg-agent.

The problem is that this only works for X11 programs – native Wayland clients are not affected. To fix that, there are two options, depending on what gpgconf --list-dirs agent-ssh-socket prints:

  • if it's a fixed path, create a file .config/environment.d/ssh.conf and add that output:

    SSH_AUTH_SOCK=/run/user/XXX/gnupg/S.gpg-agent.ssh
    

    or whatever else gpgconf happens to print.

  • if it's a temporary file that's somewhere else the next time you log in, add these lines to your .bashrc (or the equivalent of whichever shell you're using):

    if [ -z "$SSH_AUTH_SOCK" ] ; then
        export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
    fi
    dbus-update-activation-environment --systemd SSH_AUTH_SOCK
    

    This only works for shells, and other Wayland programs you start after the first shell, but that should be sufficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.