dongxingdu9594 2013-03-06 10:09
浏览 108

Git POST webhook shell_exec

I have a script running the following shell_exec cmd in PHP.

echo shell_exec('cd /var/www/Library/Laravel/ ; git pull bitbucket master ; 2>&1');

This is being called by a webhook service and all I wanted to do is just cut out having to pull in this dev environment everytime we push.

However, I do not get any output errors or anything when this route is called. Can anyone suggest why this might be?

I get this echoing from the error_log ->

error: cannot open .git/FETCH_HEAD: Permission denied

I added the apache user to git and now I get the following error

Could not create directory '/var/www/.ssh'.
Host key verification failed.
fatal: The remote end hung up unexpectedly
  • 写回答

1条回答 默认 最新

  • duanmeng1858 2013-03-06 18:02
    关注

    I see a few problems here:

    1) your exec line "...; git pull bitbucket master ; 2>&1" should be "... git pull bitbucket master 2>&1" -- the extraneous semicolon is likely preventing you from seeing the standard error output.

    2) you found the ownership problem, so...

    3) I'm guessing you have an "ssh" based git URL. The first time you run SSH as a user it will try to validate host key (SSH id of the other side). The default behavior of SSH is to fail if the tool is not interactive and you have not yet accepted the key. Alternately, you'd see the same behavior if you've accepted the key but it has since changed. You would solve these two different problems differently.

    The "right" way to fix this would be to manually run the command (as that user with the appropriate HOME variable set) and manually accept the key so subsequent commands will "just work".

    Another possibility is to override SSH's default behavior -- see the documentation for the "StrictHostKeyChecking" SSH option. You can do some hacking to pass this on the command line or create a ~/.ssh/config file specifying the option. (NOTE: I recommend the first solution, not this one unless you understand the security implications.)

    And lastly, I suspect you'll also need to set up your SSH private key to allow you to pull as that user as well.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog