PHP Github上拉脚本错误“权限被拒绝(公钥)” [英] PHP Github Pull script error 'permission denied (publickey)'

查看:310
本文介绍了PHP Github上拉脚本错误“权限被拒绝(公钥)”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个PHP脚本来执行GitHub上拉:

I've set up a PHP script to perform a GitHub pull:

这是包含在我的文件夹Github上 /家庭/ mysite的/的public_html / github上

This is contained in my Github folder /home/mysite/public_html/github

github_pull.php

github_pull.php

<?php
echo `git pull 2>&1`;
?>

我的服务器就已经有SSH公共密钥,因为如果我执行 git的拉航站楼:

ssh username@host.com
cd public_html/github
git pull

这成功的作品的(但是我必须为RSA输入密码钥匙第一)更新:密码已不再需要(见注释)

然而,当我运行 github_pull.php 我收到以下错误:
权限被拒绝(公钥)。致命:远程最终挂了意外。

However, when I run github_pull.php I get the following error: Permission denied (publickey). fatal: The remote end hung up unexpectedly

SSH密钥被包含在 /home/mysite/.ssh/id_rsa

The SSH key is contained at /home/mysite/.ssh/id_rsa

当我运行

<?php echo `whoami`;

它输出的mysite

推荐答案

以下内容添加到您的.ssh /配置

Add the following to your .ssh/config

Host github_server
  HostName github.com
  User git
  IdentityFile /path/to/your/private_key

编辑您的.git / config并从

Edit your .git/config and update the remote repo URL from

url = git@github.com:git_repo_name.git

url = git@github_server:git_repo_name.git

这应该使用给定键帮你登录到服务器。替换在上到你的机器上满实际路径的关键路径。实际回购名称替换回购名称。请注意,用户mysite的访问密钥文件。您可以测试使用的fopen从PHP和确认。

That should help you login to the server using the given key. Replace the path to the key in the above to the full actual path on your machine. Replace the repo name with the actual repo name. Do note that the user 'mysite' has access to the key file. You can test that using fopen from PHP and confirm.

这篇关于PHP Github上拉脚本错误“权限被拒绝(公钥)”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆