References:
Note: Install SSH as described in ssh.
Edit bash config file with
nano ~/.bash_profile
Add (at the top of the file)
# Set variable for using ssh-agent with systemd service
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
Create a config file with
nano ~/.ssh/config
Add
AddKeysToAgent yes
As user, enable
systemctl --user enable ssh-agent.socket --now
Check status with
systemctl --user status ssh-agent.socket
The first time you run ssh, the key will be passed to the agent after you enter the password.
Alternatively, you may pass a key to the agent with
ssh-add ~/.ssh/id_rsa