Last active
December 17, 2015 15:39
-
-
Save aumgn/5633023 to your computer and use it in GitHub Desktop.
ssh-agent for Windows Contrary to most scripts available on the web, this one allows to use the same ssh-agent for all shell sessions.
It works by specifiying an explicit socket '/tmp/ssh-agent' and using 'ps' to retrieve the pid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init_ssh_agent { | |
echo "Initializing new SSH agent..." | |
rm -f /tmp/ssh-agent | |
eval `ssh-agent -a /tmp/ssh-agent` | |
} | |
function setup_existing_ssh_agent { | |
echo "Using existing SSH agent..." | |
export SSH_AUTH_SOCK=/tmp/ssh-agent | |
export SSH_AGENT_PID=$(ps -s -u $USERNAME | grep ssh-agent | cut -d' ' -f4) | |
} | |
if [[ -n $(ps -f -u $USERNAME | grep ssh-agent) ]]; then | |
setup_existing_ssh_agent | |
else | |
init_ssh_agent | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment