title: How to troubleshoot when phpseclib key login fails?
body: <p>I've been trying out phpseclib, to run a simple SSH session to various cloud servers. Each time using key login.</p>
  
  <p>A test with key that has no password protection is fine: I tried one on standard port 22, then another on a non-standard port, and both worked. (Both are on Amazon EC2, different regions.)</p>
  
  <p>But the first test I tried failed, with:</p>
  
  <pre><code>SSH_MSG_USERAUTH_FAILURE: publickey,password
  </code></pre>
  
  <p>It has a password-protected key, with a non-standard port. Here is my script (with names changed to protect the innocent):</p>
  
  <pre><code>include('Net/SSH2.php');
  include('Crypt/RSA.php');
  
  $ssh = new Net_SSH2('10.1.2.3', /*port*/999);
  $key = new Crypt_RSA();
  
  $key-&gt;setPassword('secrets');
  $ret = $key-&gt;loadKey(file_get_contents('/home/tester/.ssh/my_private_key'));
  if(!$ret){
      echo "loadKey failed\n";
      exit;
      }
  
  if (!$ssh-&gt;login('ubuntu', $key)) {
      print_r($ssh-&gt;errors);
      exit("Login Failed\n");
      }
  
  echo $ssh-&gt;exec('pwd');
  echo $ssh-&gt;exec('ls -la');
  </code></pre>
  
  <p>I did <code>ssh-agent -d /home/tester/.ssh/my_private_key</code> (to force it to prompt me), then used ssh on the commandline, and it worked. And if I skip setting a password, the <code>loadKey()</code> returns false.</p>
  
  <p>So, now I'm wondering if the type of key is not supported? The "bad" key starts like this:</p>
  
  <pre><code>-----BEGIN DSA PRIVATE KEY-----
  Proc-Type: 4,ENCRYPTED
  DEK-Info: DES-EDE3-CBC,A541E5B6B9077483BCEF845
  
  YMMV4.....
  </code></pre>
  
  <p>whereas the "good" keys start with:</p>
  
  <pre><code>-----BEGIN RSA PRIVATE KEY-----
  YMMVgIBab54...
  </code></pre>
  
  <p>I found <a href="https://stackoverflow.com/q/13908284/841830">this question</a> where the Proc-Type and DEK-Info appear to be fine, but his is RSA, not DSA. So is DSA the problem? (But if so, shouldn't phpseclib have complained when I tried to do <code>loadKey()</code>?)</p>
  
  <p>Any suggestions about how I can get more information on the problem? (Without posting the actual keys here!)</p>