Created
December 8, 2022 10:03
-
-
Save mitsos1os/e77e57f4cff4400ae75bdc32531c1d7e to your computer and use it in GitHub Desktop.
Modified systemd unit file for gnome-keyring-daemon in WSL2 after enabling system
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
# Works on WSL2 installation with enabled SystemD (https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/) | |
# File location: /usr/lib/systemd/user/gnome-keyring-ssh.service | |
# You can try it out by issuing: | |
# 1. `systemctl --user daemon-reload` -- will load the newly added file | |
# 2. `systemctl --user start gnome-keyring-ssh.service` -- will start the keyring daemon so that you can verify that it works | |
# 3. `systemctl --user enable gnome-keyring-ssh.service` -- will enable the service to run on system startup | |
[Unit] | |
Description=Start gnome-keyring as SSH agent | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/bin/sh -ec 'if [ -z "${SSH_AUTH_SOCK}" ] && \ | |
! grep -s -q X-GNOME-Autostart-enabled=false ~/.config/autostart/gnome-keyring-ssh.desktop /etc/xdg/autostart/gnome-keyring-ssh.desktop; then \ | |
eval $$(/usr/bin/gnome-keyring-daemon --start --components ssh,secrets,pkcs11); \ | |
dbus-update-activation-environment --verbose --systemd SSH_AUTH_SOCK=$$SSH_AUTH_SOCK SSH_AGENT_LAUNCHER=gnome-keyring; \ | |
initctl set-env --global SSH_AUTH_SOCK=$$SSH_AUTH_SOCK || true; \ | |
fi' | |
ExecStopPost=/bin/sh -ec 'if [ "${SSH_AGENT_LAUNCHER}" = gnome-keyring ]; then \ | |
dbus-update-activation-environment --systemd SSH_AUTH_SOCK=; \ | |
initctl unset-env --global SSH_AUTH_SOCK || true; \ | |
fi' | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment