我试图设置这个EC2实例来侦听来自Github的webhook,然后运行一个git pull 。 networking在用户“apache”下运行。
我是以下: http : //jondavidjohn.com/blog/2012/10/git-pull-from-a-php-script-not-so-simple
当我得到你开始运行的最后一部分:
sudo -u www git pull
我的服务器要求我input“ec2-user”的密码。 据我所知,你不明白,你只是得到一个关键和我的生活,我不知道如何运行git拉。
从我的apache error_log:
Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
据我所知,我需要添加一个SSH密钥,但我不能,因为我不知道密码,以EC2用户运行该命令的用户“Apache”。
我尝试了一切:
<?php // POST http://example.com/pull.php putenv("HOME=/var/www/worker"); echo shell_exec(" #!/bin/sh cd /var/www/html/worker/ || exit unset GIT_DIR git pull 2>&1 ");
其他人遇到这个?
当我运行sudo bash我正在运行的东西
[root@ip-10-233-33-33]#
当我运行cat /etc/passwd我可以确认我需要使用的帐户名为apache 。
当我运行su apache我得到:
This account is currently not available.
你有没有按照整篇文章。 尤其是:
我发现一个更简单的方法是给apache用户一个主目录(通过/ etc / passwd)和一个.ssh目录,然后以apache用户(www)的身份运行ssh-keygen命令,
$> sudo -u www ssh-keygen -t rsa这将创build密钥,并将其置于预期的位置,同时应用适当的权限。
然后,我将该密钥添加为BitBucket存储库的只读密钥,并且按预期工作。