You are not logged in.

#1 2020-12-07 17:55:41

tsj
Member
Registered: 2017-07-06
Posts: 12

[SOLVED] ssh-agent.service fails during "stop"

I created a file called ~/.config/systemd/user/ssh-agent.service with exactly the content as in https://wiki.archlinux.org/index.php/SS … stemd_user
The unit starts correctly and ssh-agent functions properly. However, if I ask the service to stop with "systemctl --user stop ssh-agent.service" it does indeed stop, but not without failing in the process:

Dec 07 12:31:53 box systemd[1385]: Stopping SSH key agent...
Dec 07 12:31:53 box systemd[1385]: ssh-agent.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Dec 07 12:31:53 box systemd[1385]: ssh-agent.service: Failed with result 'exit-code'.
Dec 07 12:31:53 box systemd[1385]: Stopped SSH key agent.

It's not a major issue since the agent does get killed, but to avoid confusion when looking at logs I'd like to avoid entering the failed state whenever the unit is stopped normally. I do not know how to debug this further as I don't see much helpful output. Changing the systemd log-level to "debug" seems to generate no additional output.

~/.config/systemd/user/ssh-agent.service:

[Unit]
Description=SSH key agent

[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
# DISPLAY required for ssh-askpass to work
Environment=DISPLAY=:0
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK

[Install]
WantedBy=default.target

Last edited by tsj (2020-12-09 20:39:02)

Offline

#2 2020-12-09 20:38:36

tsj
Member
Registered: 2017-07-06
Posts: 12

Re: [SOLVED] ssh-agent.service fails during "stop"

Learned that ssh-agent quits normally with code 2. This happens here: https://github.com/openssh/openssh-port … nt.c#L1225

systemd has a mechanism to deal with this, just place a minus before the ExecStart command. https://www.freedesktop.org/software/sy … .8.3.6.2.4

ExecStart=-/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK

Offline

Board footer

Powered by FluxBB