3

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.

1
  • It's too bad no one has actually answered this question. Why did you accept VonC's answer since it eas clearly not correct. The latter part of his response in comments also makes no sense.
    – Otheus
    Aug 26, 2022 at 12:33

1 Answer 1

0

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 192.68.24.1
IdentityFile "path to your private ssh key without passphrase"

You would then use an ssh url like:

git fetch anEntry:yourRepo
4
  • Can I force it to not use any key since this repo doesn't need one? Oct 23, 2013 at 7:43
  • @PaulTarjan Is the url for this repo an ssh one?
    – VonC
    Oct 23, 2013 at 7:44
  • yes, otherwise my cronjob wouldn't be trying my key, right? Oct 23, 2013 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, 2013 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .