0

My question is very similar to many others out there, however I'm fairly new to github and how how ssh keys are handled. I have set up a launchd file which runs a script every hour that includes a git push. When I run the script manually I push just fine, but when it runs automatically through cron/launchd, I get a "permission denied (public key) fatal could not read from remote". I have set up my ssh keys using (github documentation).

I'm running MAC OSX Yosemite.

Posts I've looked at: Pushing to GitHub using a cron job -- Permission denied (publickey)

git push via cron

cron git push with ssh key

I am confused by the solutions out there, regarding setting up a keychain (is this mac osx management system or something separate?) as well as what it means to set SSH_AUTH_SOCK to my cron job.

Currently my file setup is ~/myname/folder_1/githubrepo

With my my gitpush script is stored ~/myname/folder_1/githubrepo

With the RSA keys stored in ~/.ssh/ (id_rsa)

Any push would be wonderful, perhaps a more dumbed step by step process would be wonderful.

Community
  • 1
  • 1
Kevin Zen
  • 111
  • 1
  • 7
  • 2
    Is your launchd job being run as you? i.e., have you specified `UserName ` as per the instructions in [the manual](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html)? – houtanb Nov 25 '15 at 08:58
  • Also, don't use cron os OS X. Just use launchd. – houtanb Nov 25 '15 at 08:59
  • Nothing changed, previously ran it as user agent, switched to global daemon and specified UserName, still get the same error. And yup launchd works better, I just put cron because it seems most of other similar stack overflow questions revolved around cron – Kevin Zen Nov 25 '15 at 19:05
  • cron works well on linux but the OS X way is to use launchd. Another idea would be to create a passwordless ssh key to be used with git and see if that helps out. Follow the instructions [here](https://matharvard.ca/posts/2011/aug/11/git-push-with-specific-ssh-key/) and [here](http://www.keybits.net/2013/10/automatically-use-correct-ssh-key-for-remote-git-repo/). But, basically, you're going to have to find out who the process is being run as so you can associate an ssh key with it. – houtanb Nov 25 '15 at 22:43
  • Thanks for the help, it actually worked after specifying UserName for a second, but after modifying something it broke and I was never able to get it back to it's working state again. I ended up pushing through HTTPS, specifying url origin with my username and password. – Kevin Zen Dec 11 '15 at 22:39

0 Answers0