/*
include('Crypt/RSA.php');
include('Net/SSH2.php');

$key = new Crypt_RSA();
//$key->setPassword('whatever');
$key->loadKey(file_get_contents('se-ee.pem'));

$ssh = new Net_SSH2('xxx.xxx.xx.xxx');
if (!$ssh->login('xuser', $key)) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
*/

$eKey = file_get_contents('ee-xx.pem');
$key_private = openssl_get_privatekey($eKey);
$keyDet=openssl_pkey_get_details($key_private);
$key_public = openssl_pkey_get_public(array($keyDet['key'],""));
$keyPDet=openssl_pkey_get_details($key_public);


$connection = ssh2_connect('xx.xx.xx.xx', 22, array('hostkey'=>'ssh-rsa'));

if (ssh2_auth_pubkey_file($connection, 'xuser',
                          $key_public,
                          $keyPDet, 'secret')) {
  echo "Public Key Authentication Successful\n";
} else {
  die('Public Key Authentication Failed');
}

官网

http://phpseclib.sourceforge.net/