Skip to content

Instantly share code, notes, and snippets.

@vancluever
Created January 4, 2018 05:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vancluever/e8e38a3255ddeeb3149109519f42aad5 to your computer and use it in GitHub Desktop.
Save vancluever/e8e38a3255ddeeb3149109519f42aad5 to your computer and use it in GitHub Desktop.
SSH agent systemd service
[Unit]
Description=OpenSSH Agent
[Service]
Type=simple
Environment=SSH_AUTH_SOCK="%t/ssh-agent.socket"
ExecStart=/usr/bin/ssh-agent -D -t 14400 -a "${SSH_AUTH_SOCK}"
[Install]
WantedBy=default.target
@vancluever
Copy link
Author

This goes into ${HOME}/.config/systemd/user/ssh-agent.service.

After this is done, you can run systemctl --user daemon-reload to make it visible. Then, run systemctl --user enable ssh-agent.service to enable it, and it will start on the next login (or you can just start it yourself).

@danielkrajnik
Copy link

danielkrajnik commented Jan 1, 2022

how to access SSH_AUTH_SOCK from a system unit file run as a User=?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment