Replies: 4 comments
-
The proper way (as close as it gets at the moment, since
[Unit]
Description=Start gnome-keyring as SSH agent
Before=graphical-session-pre.target default.target ssh-agent.service
PartOf=graphical-session-pre.target
After=dbus.service
After=dbus.socket
Wants=dbus.socket
[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); \
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 systemctl --user enable gnome-keyring-ssh.service
if [ -n "${XDG_RUNTIME_DIR-}" ]; then
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR%/}"
fi
export XDG_RUNTIME_DIR
systemctl is-system-running --quiet --wait
if [ -z "${SSH_AUTH_SOCK-}" ]; then
eval "$(systemctl --user show-environment | grep -e '^SSH_AUTH_SOCK=')"
fi
if [ -z "${SSH_AUTH_SOCK-}" ] || [ ! -S "${SSH_AUTH_SOCK-}" ]; then
SSH_AUTH_SOCK="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/keyring/ssh"
fi
export SSH_AUTH_SOCK |
Beta Was this translation helpful? Give feedback.
-
@Alexander-Shukaev thanks for your help.
Thanks |
Beta Was this translation helpful? Give feedback.
-
Despite my questions above, eventually this seems to work. On my system it seems I have to wait for systemd-networkd-wait-online to timeout (2 minutes). I think systemd-networkd-wait-online is waiting for docker0, which is perhaps brought up by docker.service, which contains "After=network-online.target".
|
Beta Was this translation helpful? Give feedback.
-
I fixed the degraded state caused by the systemd-networkd-wait-online timeout by creating an override.conf:
This results in a message to the terminal
which is apparently caused by "systemctl --user show-environment" in ~/.profile executing too early. However, the final "SSH_AUTH_SOCK="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/keyring/ssh" in ~/.profile seems to get the job done. |
Beta Was this translation helpful? Give feedback.
-
What is the best way to get gnome-keyring-daemon started with systemd under WSL2?
This seems to mostly work at the end of ~/.bashrc. The login keyring, ssh keys, and gpg keys all are available, although the login keyring is locked on the first access attempt but prompts for the password.
Beta Was this translation helpful? Give feedback.
All reactions