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:
mysite/.git/
, and Program Files/git/bin
and cmd.exe
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!
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.
I am running Windows Server 2012 and wasn't able to get Iamz's solution to work.
I searched for ".ssh" in my C:\
and noticed that there was another .ssh folder at C:\Program Files (x86)\Git\.ssh
. I copied all the contents from C:\Users\Administrator\.ssh
to this folder, set permissions to allow IUSR access, and everything was kosher.
there are a number of php git libraries/tools. https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#git-php
personally i have been hacking with GLIP (git library in php) http://fimml.at/#glip
i have a source fork on github where i have added an archive function. basically i dynamically create a git command and use php's passthru method to call it. perhaps looking at my code might give you some insight. here's the commit https://github.com/fontvirus/glip/commit/89127f7f9a4dc61697929f36684533406f348ffe
Move your .ssh folder to userprofile dir. You can see you app profile dir in this global variable $_SERVER['USERPROFILE']. In my case it's C:\Windows\system32\config\systemprofile. Then give permissions to read/write to this folder (.ssh) for users: IIS_IUSRS, IUSR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With