% ssh-agent > agent.sh % source agent.sh % ssh-add ~/.ssh/id_rsa
% .bash_profile
GREP=grep
test=`/bin/ps -ef | $GREP ssh-agent | $GREP -v grep | /usr/bin/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 ~/.ssh/id_rsa
fi;
test -e $HOME/agent.sh && source $HOME/agent.sh
alias kagent="kill -9 $SSH_AGENT_PID"
Reference: https://drupal.star.bnl.gov/STAR/blog-entry/jeromel/2009/feb/02/ssh-quick-instructions-users-without-password
No comments:
Post a Comment