ocehb: (Default)
ocehb ([personal profile] ocehb) wrote2016-11-04 09:55 am
Entry tags:

ssh-agent.service



# cat ssh-agent.service
[Unit]
Description=OpenSSH private key agent
Wants=environment.target
Before=environment.target
IgnoreOnIsolate=true

[Service]
Type=forking
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
#PIDFile=%t/ssh-agent.pid
ExecStart=/usr/bin/ssh-agent -a $SSH_AUTH_SOCK
ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AGENT_PID=${MAINPID}
ExecStartPost=/bin/sh -c "echo ${MAINPID} > %t/ssh-agent.pid"
#ExecStop=/usr/bin/ssh-agent -k
ExecStopPost=/bin/rm -f ${SSH_AUTH_SOCK} %t/ssh-agent.pid
ExecStopPost=/usr/bin/systemctl --user unset-environment SSH_AUTH_SOCK
ExecStopPost=/usr/bin/systemctl --user unset-environment SSH_AGENT_PID

[Install]
WantedBy=default.target
# install -D -Z -m644 -oroot -groot ssh-agent.service /etc/systemd/user/ssh-agent.service
# systemctl daemon-reload
# systemctl --user enable ssh-agent
# systemctl --user start ssh-agent
# ssh-add
...
# systemctl --user status ssh-agent
* ssh-agent.service - OpenSSH private key agent
   Loaded: loaded (/etc/systemd/user/ssh-agent.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-11-04 09:34:05 EET; 13min ago
  Process: 2524 ExecStartPost=/bin/sh -c echo ${MAINPID} > %t/ssh-agent.pid (code=exited, status=0/SUCCESS)
  Process: 2522 ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AGENT_PID=${MAINPID} (code=exited,
  Process: 2520 ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AUTH_SOCK=${SSH_AUTH_SOCK} (code=e
  Process: 2518 ExecStart=/usr/bin/ssh-agent -a $SSH_AUTH_SOCK (code=exited, status=0/SUCCESS)
 Main PID: 2519 (ssh-agent)
   CGroup: /user.slice/user-1000.slice/user@1000.service/ssh-agent.service
           `-2519 /usr/bin/ssh-agent -a /run/user/1000/ssh-agent.socket

Nov 04 09:34:05 vbox3.test.net systemd[1530]: Starting OpenSSH private key agent...
Nov 04 09:34:05 vbox3.test.net systemd[1530]: Started OpenSSH private key agent.



Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org