Enter your ssh-passphrase once, use it many times, even from crontab

Here is a way to use ssh-agent, ssh-add without having to type you password every session. Just once (when the machine has been rebooted) you will have to enter you passphrase, from then on you are authenticated. Here is the script you will have to add to your .bashrc or .profile in you homedirectory:

variables=~/.ssh/variables

sshadd() {
source "$variables" > /dev/null
ssh-add -l > /dev/null 2>&1
case "$?" in
  1)
   ssh-add > /dev/null 2>&1
  ;;
  2)
   rm "$variables"
   sshagent
  ;;
esac
}

sshagent() {
if [ -f "$variables" ] ; then
  sshadd
else
  ssh-agent -s > $variables
  sshadd
fi
}

sshagent

Have fun, I have been using this great hint for quite some time now, it seems to work perfectly!

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning robert@meinit.nl