# safely add key to ssh-agent on login
test=`ps -ef | grep ssh-agent | grep -v grep | awk '{print $2}' | xargs`
if [ "$test" = "" ]
then
# there is no agent running
if [ -e "$HOME/agent.sh" ]
then
# remove the old file
rm -f $HOME/agent.sh
fi
# start a new agent
ssh-agent | grep -v echo &> $HOME/agent.sh
ssh-add /root/.ssh/id_rsa
fi
test -e $HOME/agent.sh && source $HOME/agent.sh
Adapted from: http://drupal.star.bnl.gov/STAR/blog-entry/jeromel/2009/feb/06/how-safely-start-ssh-agent-bashrc
No comments:
Post a Comment