[lug] neat little ssh trick
    dan radom 
    dan at radom.org
       
    Sat Apr  6 15:32:18 MST 2002
    
    
  
I've been using ssh hostkey authentication for a while now, and I've always wanted a way to make cron aware of my running ssh-agent for passwordless scp action from cron.  Here's how I've made that work...
lunar:~$ grep ssh-agent .xinitrc
ssh-agent -s &> $HOME/tmp/sshagent-vars.sh && . $HOME/tmp/sshagent-vars.sh
lunar:~$ cat tmp/sshagent-vars.sh 
SSH_AUTH_SOCK=/tmp/ssh-XXui8WMv/agent.22994; export SSH_AUTH_SOCK;
SSH_AGENT_PID=22995; export SSH_AGENT_PID;
echo Agent pid 22995;
Now I just do things like ...
#!/bin/sh
source /home/graffix/tmp/sshagent-vars.sh
rsync -avz -e ssh --delete --exclude "bin/" --exclude "icons/" --exclude "include/" --exclude "man/" --exclude "proxy/" mars:/storage/apache/ /home/graffix/backup/html
Enjoy,
dan
    
    
More information about the LUG
mailing list