求教git的webhook服务器端处理

百度的教程
git平台:oschina
服务器系统:Centos
php版本:7.1.8
按照上面的教程,密匙都配置好了,oschina里面也设置了

clipboard.png
ssh也连接上了

clipboard.png
所有的文件夹都给daemon了,daemon是我的apache用户

git.sy-btc.com/index.php文件的内容

<?php
    echo exec('cd /www/bika/ && /usr/bin/git pull  2>&1', $o);
    var_dump($o);
?>

通过域名访问报错

and the repository exists.array(5) { [0]=> string(29) "Host key verification failed." [1]=> string(45) "fatal: Could not read from remote repository." [2]=> string(0) "" [3]=> string(51) "Please make sure you have the correct access rights" [4]=> string(26) "and the repository exists." }

在命令行执行 php git.sy-btc.com/index.php

clipboard.png

各种百度和谷歌了,一直解决不了

更新

猜想是不是生成的密匙daemon用户读取不了

sudo -u daemon ssh-keygen -t rsa -C "email@email.com"

于是用上面这句生成了daemon的密匙,但是报错/sbin/.ssh/没有权限,执行chown daemon:daemon /sbin/.ssh,然后成功生成了密匙对,再将公钥添加到oschina。
再次访问域名报错error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied,再次将.git/logs/refs/remotes/origin/master的用户设置为daemon,至此居然成功!!!

那里搞搞这里搞搞,都不知道输入的命令哪些有用哪些没用,是否不安全也不知道,有没有大神解答一下哪里的设置不安全

阅读 2.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题