title: Trying to connect using ssh2_auth_pubkey_file()
body: <p>I am trying to make a php script that runs on the terminal that would connect to a remote server by ssh and retrieve a file. this is my code so far</p>
  
  <pre><code>#!/usr/bin/php -q
  &lt;?php
  $cwd = dirname(__FILE__).'/';
  $filename = 'retrive-this.file';
  $host = 'hostip';
  
  $connection = ssh2_connect($host, 22, array('hostkey'=&gt;'ssh-rsa'));
  $methods = ssh2_auth_pubkey_file($connection, 'remoteuser',
                                   $cwd.'ssh/id_rsa.pub',
                                   $cwd.'ssh/id_rsa', "it's an inception");
  var_dump($methods);
  
  //ssh2_scp_recv($connection, "/remote/server/path/to/$filename", $cwd.$filename);
  ?&gt;
  </code></pre>
  
  <p>for now I am having problems with the <code>ssh2_auth_pubkey_file()</code> function, when I run the script it returns this:</p>
  
  <pre><code>PHP Warning:  ssh2_auth_pubkey_file(): Authentication failed for remoteuser using public key in /home/tonyl/Projects/get-file-ssh.php on line 10
  bool(false)
  </code></pre>
  
  <p>The key files have permission <code>-rw-r--r--</code> (644). Also the public key is already added to the remoteuser's authorized keys. I am able to ssh using the ssh command as normal, so I don't think it is a ssh authorization problem, but who knows. I am new to ssh and the ssh2 php library.</p>
  
  <p>I can connect using <code>ssh2_auth_password()</code> if I enable it in the remote sshd_config file, but I don't want to do that since it decreases security tranfer.</p>
  
  <p>Any ideas of what I can do.</p>