Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push via cron

Tags:

git

ssh

cron

I'm trying to run a git push from cron. When I do the command interactively on the shell it's going through fine. When running the command from my user's crontab, cron delivers the error message

Permission denied (publickey).

I presume it hasn't to do with finding or reading my ~/.ssh/id_rsa, as I can cat the file from cron alright. UID and EUID are set fine in the cron job. - Any ideas?

UPDATE

I got it working when supplying the environment key SSH_AUTH_SOCK to my cron job, but I'm concerned that this is only valid as long as I'm logged in. I'm looking for a solution that works independent of interactive logins.

like image 418
ThomasH Avatar asked Nov 03 '11 12:11

ThomasH


1 Answers

As explained here, it can be due to the lack of knowledge from the cron session shell of the ssh agent.
If that is the case (ie if you are using private ssh keys with a passphrase), keychain is the usual solution (as mentioned here).
More details in this example: "Passwordless connections via OpenSSH using public key authentication, keychain and AgentForward".

like image 179
VonC Avatar answered Oct 16 '22 14:10

VonC