connect-ssh-agent.sh

#!/bin/sh
##############################################################################
##  connect-ssh-agent.sh:  connect to a running ssh-agent for $USER
##############################################################################
#
#   The following command returns the PID of the currently running
#   ssh-agent process; This value needs to get stored into
#   SSH_AGENT_PID
#
#      ps -u $USER | grep ssh-agent | sed -e 's/^\s*//;' | cut -d' ' -f1
#
export SSH_AGENT_PID=`ps -u $USER | grep ssh-agent | sed -e 's/^\s*//;'\
 | cut -d' ' -f1`
#
#   The other value we want in order to be able to use an instance of
#   ssh-agent is the SSH_AUTH_SOCK value - this is a file system name
#   a socket maintained by the ssh-agent instance.  It will be in the
#   ${TMP}/ directory space...
#                                                                                                                                    
export SSH_AUTH_SOCK=`ls --color=none /tmp/ssh-*/agent.*`
#
echo SSH_AGENT_PID: $SSH_AGENT_PID
echo SSH_AUTH_SOCK: $SSH_AUTH_SOCK
echo "Adding default .ssh/id_dsa using ssh-add..."
ssh-add
echo kthxbai.