useful cygwin ssh-agent script

This is n generations tweaked, but it's now useful for me under any of my 
*nix hosts. Previously on win32 I was doing all kinds of nasty stuff with 
setx to push these variables into the global NT environment space, but the 
file approach is much simpler. (However, people should be cognizant of the 
potential dangers of ssh-agent under cygwin [1], though under a local 
netstat and remote portscan it does not appear that the port specified in 
/tmp/ssh-foo is accessible to anyone ...?)

[1] http://www.cygwin.com/ml/cygwin/2001-01/msg00063.html

SSH_ENV=$HOME/.ssh/environment

function start_agent {
     echo "Initialising new SSH agent..."
     /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
     echo succeeded
     chmod 600 ${SSH_ENV}
     . ${SSH_ENV} > /dev/null
     /usr/bin/ssh-add;
}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then
     . ${SSH_ENV} > /dev/null
     #ps ${SSH_AGENT_PID} doesn't work under cywgin
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
         start_agent;
     }
else
     start_agent;
fi
--
Regards,          http://www.mit.edu/~reagle/
Joseph Reagle     E0 D5 B2 05 B6 12 DA 65  BE 4D E3 C1 6A 66 25 4E
MIT LCS Research Engineer at the World Wide Web Consortium.

* This email is from an independent academic account and is
not necessarily representative of my affiliations.

Received on Friday, 8 June 2001 14:32:32 UTC