Hello,

i am using ssh with the bash under OS X.

To have a simple way to use ssh-agent, i wrote the following peace of
code, that i found somewhere in the internet, into mo .profile:

################################################## #####################
#
# This is for ssh-agent
#
################################################## #####################

#socketfile will be the value of SSH_AUTH_SOCK or defaultvalue
socketfile=${SSH_AUTH_SOCK:=/Users/${USER}/tmp/ssh/ssh-agent.socket}

#now, SSH_AUTH_SOCK is known outside:
export SSH_AUTH_SOCK=${socketfile}

#
# IF ssh-agent can not communicate with ssh-agent,
# it will return error 2
#

ssh-add -l &> /dev/null
if [ $? -eq 2 ]; then
#no ssh-agent known, remove the socketfile
/bin/rm -f ${socketfile}
#and start ssh-agent with the predefined socketfile
eval `/usr/bin/ssh-agent -a ${socketfile}`
/bin/chmod 600 ${socketfile}
#finaly, add identity
ssh-add
fi

################################################## ######################

This seems to work fine, but when i remove the file $SSH_AUTH_SOCK by
hand, then this does not work anymore. Maybe, the test, wether ssh-agent
is running or not, should use the pid of this process. So i have two
questions:
1. is it save, to run this in the .profile?
2. how can i get the pid of a process?

Thank you for any hints
Wolfgang