rmirabelle rmirabelle - 2 months ago 16
Git Question

git pull via PHP exec IIS

Easily the most difficult problem to diagnose that I have EVER experienced. I seem to be unable to call:

exec('call git pull', $output);


The process hangs and tends to take IIS with it.

exec('call git status', $output); //works fine


Here's what I've done:


  • Generated RSA key added to github (passcode is blank)

  • Everyone has permission on
    mysite/.git/
    , and
    Program Files/git/bin
    and
    cmd.exe

  • Tried the ssl cert fix mentioned in other posts with 'slash' issue

  • Tried using https:// instead of SSH

  • Tried piping to stderr
    2>NUL
    and
    2>&1



Clearly, there's a permissions issue where
exec
calls
cmd.exe
which in turn calls
git.exe
, which in turn calls
sh.exe
to connect to github, which in turn makes use of
git-pull
and possibly
git-send-pack
and GOD KNOWS what else.

I'm guessing 'sh.exe' determines the current user is IUSR and cannot find the RSA key to authenticate with.

If I could figure out how to
ssh-keygen
the IUSR account, I would have tried that.

If I could figure out how to
exec
git bash instead of git (via
cmd.exe
) I would have tried that.

Here's the question in it's simplest form:

How do I pull from my github repo via PHP's
exec
method?


The problem certainly seems to be with SSH, but I'm totally at the end of everything to try.

Help!

Answer

I faced the same problem today and used Process Monitor to see what was going on and found that for some reasons sh.exe looked for the keys in C:\Windows\SysWOW64\config\systemprofile\.ssh. So I copied everything in C:\Users\Administrator\.ssh to that folder and it worked perfectly.

Comments