Skip to content

Instantly share code, notes, and snippets.

@maxwellb
Created October 29, 2019 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxwellb/0b0e29f829923c6a03c52873c84ebba6 to your computer and use it in GitHub Desktop.
Save maxwellb/0b0e29f829923c6a03c52873c84ebba6 to your computer and use it in GitHub Desktop.
bashrc snippet - ssh-agent.service
# User mode service for ssh-agent -- set the environment variables
SSH_AGENT_PID=$(systemctl --user show ssh-agent.service | grep ^MainPID= | cut -d= -f2)
if [ "0" = "${SSH_AGENT_PID}" ]; then
systemctl --user restart ssh-agent.service
SSH_AGENT_PID=$(systemctl --user show ssh-agent.service | grep ^MainPID= | cut -d= -f2)
fi
export SSH_AGENT_PID
export SSH_AUTH_SOCK="/run/user/$(id -u)/openssh_agent"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment