Automate git-pull, stuck with keychain

command-line-interfacegitkeychainshellunix

I'd like to create a cronjob to automatically run a git-pull every minute.
The problem is that my repo is private, I had to create keys on my system (Ubuntu Server 12.04). I installed keychain and ssh-agent now prevents the system from asking me the passphrase everytime. The problem is that it doesn't work from crontab! Why from shell it works and from crontab I get asked the passphrase?

Best Answer

In your script, are you doing an $(eval ssh-agent), and then an ssh-add <private_key>?

To verify, do an ssh-add -l before doing the git pull to make sure your keys are where they should be.

[edit] Try making a script like this:

#!/bin/bash
set -e 
cd /var/www/GITREPO 
eval $(ssh-agent) 
ssh-add /home/multiformeingegno/.ssh/id_rsa
ssh-add -l
git pull
Related Topic