title: known_hosts file permissions issue when trying to git pull from PHP
body: <p>I'm trying to set up a simple PHP script that can do a <code>git pull</code> when you go to a particular URL on an AWS Amazon Linux 2 AMI test web server I have set up.</p>
  
  <p>I ran into some issues trying to do that though, and have since been following this article to try to work things out: <a href="https://jondavidjohn.com/git-pull-from-a-php-script-not-so-simple/" rel="nofollow noreferrer">https://jondavidjohn.com/git-pull-from-a-php-script-not-so-simple/</a></p>
  
  <p>I'm stuck on the step where the author says to run <code>sudo -u www git pull</code>.</p>
  
  <p>In my system, <code>apache</code> is the Apache user that we need to do a <code>git pull</code> for in order to add the necessarily SSH key info, but it's not working. When I try to run the following:</p>
  
  <pre><code>sudo -u apache git pull
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>I don't know if this is an issue, but there is no <code>.ssh</code> directory under <code>/usr/share/httpd</code>. There is a <code>known_hosts</code> file under <code>~/.ssh</code>, so maybe that's the one I need to worry about? I'm not really sure.</p>
  
  <p>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.</p>