I'd suggest using keychain. It automatically takes care of all of this 
for you.
http://www.gentoo.org/projects/keychain/

Chad C. Walstrom wrote:
> Just a tip for using ssh-agent(1) effectively in BASH(1).  If you take
> advantage of functions, you can reduce the number of ssh-agent's you
> have running on any one system to one per host.  An added advantage is
> that if you can refresh/set the ssh-agent environment with any open
> shell on that host.
> 
>     # sagent -- Update current environment w/ssh-agent
>     #  * Checks for presense of stamp file, sources it
>     #  * Checks for presense of ssh-agent process
>     #  * Starts ssh-agent if not already running, saving stamp file
>     sagent(){
>         if [ -e $HOME/.ssh-agent.$HOSTNAME ]
>         then
>             source $HOME/.ssh-agent.$HOSTNAME
> 
>             if (ps -ef|grep $USER|grep -v grep|grep $SSH_AGENT_PID > \
>                     /dev/null)
>             then
>                 return 0
>             else
>                 rm $HOME/.ssh-agent.$HOSTNAME
>             fi  
>         fi
>         
>         eval $(ssh-agent -s|tee $HOME/.ssh-agent.$HOSTNAME)
>     }
> 
> Quick summary of ssh-agent: allows you to type in a password once for
> any private key you add.
> 
>     bash$ ssh-add <file>
> 
> A good alias to include with the above function is 'addids'.
> 
>     # addids -- Add known SSH keys
>     alias addids="ssh-add ~/.ssh/id{entity,_dsa,_rsa}"
>