bashrc, bash_aliases: in cygwin, only launch ssh-agent when the first "ssh" command is executed

This commit is contained in:
josh committed 2014-03-19 09:20:39 -04:00
1 parent 034e52399b
commit ab87b07e83
2 files changed
+32 -20

No files matched your search

+3 -20
View File
@@ -7,27 +7,10 @@ if [ -f "${HOME}/.bash_aliases" ]; then
fi
if [ -e /bin/cygwin1.dll ]; then
# cygwin ssh-agent support, from
# http://www.webweavertech.com/ovidiu/weblog/archives/000326.html
export SSH_AUTH_SOCK=/tmp/.ssh_socket
ssh-add -l >/dev/null 2>&1
if [ $? = 2 ]; then
# exit status 2 means we couldn't connect to ssh-agent,
# so let's start one now
rm -f $SSH_AUTH_SOCK
ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script
. /tmp/.ssh-script
echo $SSH_AGENT_PID >/tmp/.ssh-agent-pid
ssh-add ~/.ssh/josh-walter
fi
function kill-agent
function ssh
{
pid=$(cat /tmp/.ssh-agent-pid)
kill $pid
ssh_agent_start
command ssh "$@"
}
# for scons