I'm writing a cronjob that will git fetch. I have a private key that I often use for authenticated git things (like github) which has a passphrase on it, but this specific git fetch doesn't need the key. My key is saved in the normal location of .ssh/id_rsa. Everything is wonderful when I have an ssh-agent running, but my cronjob doesn't have that luxury.

I've tried GIT_ASKPASS=echo git fetch but that just fails the passkey and won't fetch the repo.


You can use a ~/.ssh/config file in order to specify a different set of public and private key:

Host anEntry
User yourLogin
Hostname SSH IP address --eg
IdentityFile "path to your private ssh key without passphrase"

You would then use an ssh url like:

git fetch anEntry:yourRepo
  • Can I force it to not use any key since this repo doesn't need one? – Paul Tarjan Oct 23 '13 at 7:43
  • @PaulTarjan Is the url for this repo an ssh one? – VonC Oct 23 '13 at 7:44
  • yes, otherwise my cronjob wouldn't be trying my key, right? – Paul Tarjan Oct 23 '13 at 8:06
  • @PaulTarjan then you need a public/private (not passphrase-protected) key, and you need that public key to be registered in the ~git/.ssh/authorized_keys file. – VonC Oct 23 '13 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.