title: Can not login using phpseclib with RSA keys?
body: <p>I'm trying to use phpseclib to have an app executing remote commands on a linux server. I easily got it to work with username/password but I don't want to let that info in a plain text file so I want to use OpenSSH generated keys. Here is the buggy code.</p>
  
  <pre><code>&lt;?php
  include 'Crypt/RSA.php';
  include 'Net/SSH2.php';
  
  $key = new Crypt_RSA();
  $key-&gt;loadKey('key');
  echo file_get_contents('key');
  
  $ssh = new Net_SSH2('srv-test');
  if (!$ssh-&gt;login('user', $key)) {
      exit('Login Failed');
  }
  echo $ssh-&gt;exec('ls');
  ?&gt;
  </code></pre>
  
  <p>and the output is </p>
  
  <pre><code>$ php test_key.php
  
  -----BEGIN RSA PUBLIC KEY-----
  MIIBCgKCAQEAqcmSbXneDVQsMe/kjKxkaaqKPTN5GUawoeknWL20exQN4HqCAklE
  FMUcOd48ypAj4CZc9baGtjbpC3zCRDRcatJQTWbsP/P4vSe7728JPcVa0PVmqyi0
  YF5rRAnkcNVA1X4EGriYhLYGTjeEZMjvrubBBgAsYUaRbyYBauSpp7GqAP3/sVk6
  YeNRrs8nOLFYdp1bAmAlSemzixYWQ466jeHAfevD06WwSLwD1fh6Dfyt5kvsUZGp
  7KldtHwBKg/YE947YSwIFkUVOQkyx7+7BgnDhTo8sgiY4in0YK9PIC5o/gBnBqw9
  eBUjNFHTQSv8gRTEP68NfYipgy2VmcNPAQIDAQAB
  -----END RSA PUBLIC KEY-----
  
  Login Failed
  </code></pre>
  
  <p>the <code>key</code> file was generated with </p>
  
  <pre><code>ssh-keygen -f .ssh/id_rsa.pub -e -m pem
  </code></pre>
  
  <p>(the default format didn't work either) and I can normally login with the <code>id_rsa.pub</code> keyfile form the console. What am I missing ? Thank you</p>