Skip to content

Instantly share code, notes, and snippets.

@Wesseldr
Last active February 3, 2018 22:12
Show Gist options
  • Save Wesseldr/d73f67aa84dec42b7727a25927823416 to your computer and use it in GitHub Desktop.
Save Wesseldr/d73f67aa84dec42b7727a25927823416 to your computer and use it in GitHub Desktop.
Share ssh-agent between all terminals
# Add this to your .profile or .bash_profile, Tested on OsX 10.12, untested on Debian & Linux.
# Share ssh-agent between new shells and not start a new agent every new shell is opend.
# Warning! this can be a security risk for evil scripts
if [ -z "$SSH_AUTH_SOCK" ]; then
if ! pgrep -xu $(id -u) ssh-agent > /dev/null; then
ssh-agent | grep -v ^echo > ~/.ssh-agent.sh
fi
. ~/.ssh-agent.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment