Create a new systemd user unit, which starts ssh-agent
upon login to server. Will remain resident until the final session for the user has logged out.
-
Create
/etc/systemd/user/ssh-agent.service
. -
Run the following commands (under your user account, not
root
) to install the systemd unit and start:$ systemctl --user enable ssh-agent.service $ systemctl --user start ssh-agent.service
-
Add the following to
~/.bashrc
:export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
-
Logout then login, confirm
ssh-agent
is running:$ systemctl --user status ssh-agent.service $ ssh-add -L
-
Done.