Skip to content

Instantly share code, notes, and snippets.

@jinmingjian
Created October 24, 2014 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jinmingjian/3e9b719a7b9b749d8d47 to your computer and use it in GitHub Desktop.
Save jinmingjian/3e9b719a7b9b749d8d47 to your computer and use it in GitHub Desktop.
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=/bin/sh -c "ps x -o pid,comm|grep ssh-agent|cut -d' ' -f1 > %t/ssh-agent.pid"
#ExecStop=/usr/bin/ssh-agent -k
ExecStopPost=/bin/rm ${SSH_AUTH_SOCK}
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment