=> .bash_profile
#-------------------------------------------------------------------
SSH_ENV=${HOME}/.ssh/environment
function start_agent {
echo -n "Initialising new SSH agent..."
sleep 1
ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo "succeeded!"
source ${SSH_ENV}
ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
source ${SSH_ENV}
#ps ${SSH_AGENT_PID} doesn't work under cygwin
( ps -ef | grep ${SSH_AGENT_PID} \
&& ps ux| grep ${SSH_AGENT_PID} ) \
> /dev/null || {
start_agent
}
else
start_agent
fi
=> .bash_logout
#-------------------------------------------------------------------
function quit_agent {
echo -n "Cleaning ssh-agent settins..."
sleep 1
ssh-add -D
ssh-agent -k > /dev/null 2>&1
unset SSH_AGENT_PID
unset SSH_AUTH_SOCK
echo "succeeded!"
sleep 1
}
if [ ${SSH_AGENT_PID+1} == 1 ]; then
echo -n "Quit ssh-agent? (No or Yes) "
while [ 1 ]; do
read ANS
case ${ANS} in
[Yy][Ee][Ss]|[Yy])
quit_agent
exit
;;
[Nn][Oo]|[Nn])
echo "ssh-agent will continue to serve!"
sleep 2
exit
;;
*)
echo -n "What do you mean? (No or Yes)"
;;
esac
done
fi