I'm trying to set up a simple PHP script that can do a git pull
when you go to a particular URL on an AWS Amazon Linux 2 AMI test web server I have set up.
I ran into some issues trying to do that though, and have since been following this article to try to work things out: https://jondavidjohn.com/git-pull-from-a-php-script-not-so-simple/
I'm stuck on the step where the author says to run sudo -u www git pull
.
In my system, apache
is the Apache user that we need to do a git pull
for in order to add the necessarily SSH key info, but it's not working. When I try to run the following:
sudo -u apache git pull
I get the following error:
Failed to add the host to the list of known hosts (/usr/share/httpd/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I don't know if this is an issue, but there is no .ssh
directory under /usr/share/httpd
. There is a known_hosts
file under ~/.ssh
, so maybe that's the one I need to worry about? I'm not really sure.
This very much feels like a permissions error (the error message suggests as much), but I'm really not sure what file where needs to be changed and how. Any advice would be greatly appreciated. Thank you.