From 1a12b77e3d82603f6de61c462841b15ead3d73aa Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Sun, 13 Nov 2016 22:39:51 -0500 Subject: [PATCH] SSH Agent re-use --- reuse_existing_ssh_agent | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 reuse_existing_ssh_agent diff --git a/reuse_existing_ssh_agent b/reuse_existing_ssh_agent new file mode 100644 index 0000000..73acab2 --- /dev/null +++ b/reuse_existing_ssh_agent @@ -0,0 +1,17 @@ +# source: http://www.electricmonk.nl/log/2012/04/24/re-use-existing-ssh-agent-cygwin-et-al/ + + +# If no SSH agent is already running, start one now. Re-use sockets so we never +# have to start more than one session. + +export SSH_AUTH_SOCK=/home/Ryan/.ssh-socket + +ssh-add -l >/dev/null 2>&1 +if [ $? = 2 ]; then + # No ssh-agent running + rm -rf $SSH_AUTH_SOCK + ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script + source /tmp/.ssh-script + echo $SSH_AGENT_PID > ~/.ssh-agent-pid + rm /tmp/.ssh-script +fi