简体   繁体   English

来自GitHub脚本SSH的PHP Git Pull

[英]PHP Git Pull from GitHub Script SSH

This is the first time I've tried to use the GitHub service hooks to automatically deploy to my server; 这是我第一次尝试使用GitHub服务挂钩自动部署到我的服务器。 and after slowly working my way over every obstacle it looks like the very last one is the one that has done me in. 在慢慢地克服所有障碍之后,似乎最后一个障碍已将我困住了。

The initial clone of my git repository onto my web server was done through SSH, and I'm pretty sure that has something to do with my problems now. 我的git仓库到Web服务器的初始克隆是通过SSH完成的,我现在可以肯定这与我的问题有关。 My current script is the basic: 我当前的脚本是基本的:

<?php 
    echo(shell_exec('git pull 2>&1')); 
?>

But it returns "Permission denied (publickey). fatal: The remote end hung up unexpectedly"; 但是它返回“权限被拒绝(公钥)。致命:远端意外挂断”; which I know is where the script is failing to put in the SSH pass phrase I created. 我知道这是脚本无法放入我创建的SSH密码短语的地方。 I tried doing research on how to maybe get past it, but I don't even know if those would be the correct/securest things to do. 我尝试过研究如何克服它,但我什至不知道这些方法是否正确/最安全。

So can this be modified to work from here or do I need to backtrack a few steps and step away from using SSH to begin with? 因此,可以将其修改为从此处开始工作吗?还是我需要回溯几步,而不再使用SSH?

Thanks 谢谢

Can you try to replace (in your git.config file ) 您可以尝试替换(在您的git.config文件中)

ssh://github.com/<username>/<project>.git 

or 要么

https://github.com/<username>/<project>.git

with

git@github.com:<username>/<project>

Apache is probably running as a different user than the one you normally run git with via the CLI. Apache可能以不同于通常通过CLI运行git的用户身份运行。 You'll probably need to copy your .ssh/id_rsa file from /home/regularuser/ to /home/webuser/ . 您可能需要将.ssh/id_rsa文件从/home/regularuser/复制到/home/webuser/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM