-
-
Save ansemjo/b9337e330cd7dd7b6d2dd36c6400fc1b to your computer and use it in GitHub Desktop.
systemd user unit to set SSH_AUTH_SOCK variable for X11/Wayland/GNOME and make it work with GnuPG agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place this file in ~/.config/systemd/user/ssh-auth-sock.service | |
# $ systemctl --user daemon-reload | |
# $ systemctl --user enable --now ssh-auth-sock.service | |
# Add 'echo UPDATESTARTUPTTY | gpg-connect-agent >/dev/null' in your ~/.bashrc. | |
# Logout or reboot. | |
[Unit] | |
Description=Set SSH_AUTH_SOCK to GnuPG agent | |
[Service] | |
Type=oneshot | |
# disable gnome-keyring-ssh | |
ExecStartPre=/bin/bash -c 'cat /etc/xdg/autostart/gnome-keyring-ssh.desktop \ | |
<(echo "Hidden=true") > %h/.config/autostart/gnome-keyring-ssh.desktop' | |
# set environment | |
ExecStart=/usr/bin/bash -c 'systemctl --user set-environment \ | |
SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) \ | |
GSM_SKIP_SSH_AGENT_WORKAROUND="true"' | |
# See the below link for why we need GSM_SKIP_SSH_AGENT_WORKAROUND: | |
# https://git.gnome.org/browse/gnome-session/tree/gnome-session/main.c?h=3.24.0#n419 | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment