Skip to content

Instantly share code, notes, and snippets.

@alexeiz
Created September 15, 2015 13:44
Show Gist options
  • Save alexeiz/984289f5184f27388a15 to your computer and use it in GitHub Desktop.
Save alexeiz/984289f5184f27388a15 to your computer and use it in GitHub Desktop.
# source into bashrc, zshrc
# ssh-agent management functions for cygwin/msys2
export _SSH_AGENT_LOCK=/tmp/ssh-agent.lock
start_ssh_agent() {
if [ -e $_SSH_AGENT_LOCK ]; then
use_ssh_agent
else
eval `ssh-agent`
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $_SSH_AGENT_LOCK
echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >> $_SSH_AGENT_LOCK
ssh-add
fi
}
stop_ssh_agent() {
if [ -e $_SSH_AGENT_LOCK ]; then
source $_SSH_AGENT_LOCK
rm -f $_SSH_AGENT_LOCK
ssh-agent -k
fi
}
use_ssh_agent() {
if [ -e $_SSH_AGENT_LOCK ]; then
source $_SSH_AGENT_LOCK
else
echo "ssh-agent not found"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment