I love ssh-agent, but always found that running source ~/.ssh.agent annoyed me!
That was before I wrote this code, which I absolutely love:
source ~/.ssh.agent
PID=$SSH_AGENT_PID
if [ -f /proc/$SSH_AGENT_PID/cmdline ]; then
CMD=`cat /proc/$SSH_AGENT_PID/cmdline`;
if [ "$CMD" != "ssh-agent" ] ; then
PID=0
fi
else
PID=0
fi;
if [ "$PID" -eq 0 ]; then
ssh-agent > ~/.ssh.agent
source ~/.ssh.agent
ssh-add
fi;
Put simply, when added to your .bash_profile this code will ensure that your current ssh-agent is loaded. You may now ssh freely into servers without always typing that 100 character SSH Key password 🙂