Browsing articles tagged with " Using Wrapper Functions"
Feb
6
2013

PHP + SSH Authentication using a public key

  <?php $connection = ssh2_connect(‘shell.example.com’, 22, array(‘hostkey’=>’ssh-rsa’)); if (ssh2_auth_pubkey_file($connection, ‘username’, ‘/home/username/.ssh/id_rsa.pub’, ‘/home/username/.ssh/id_rsa’, ‘secret’)) { echo “Public Key Authentication Successful\n”; } else { die(‘Public Key Authentication Failed’); } ?>   This is a known bug in php: password protected private key cannot be used on certain combinaisons. See: https://bugs.php.net/bug.php?id=58573 ssh2_auth_pubkey_file() is broken when the public key file is protected with a password AND libssh2 is compiled with libgcrypt, which is what debian/ubuntu and probably others do. I’m working on a solution for this bug, but if you need this working rebuild libssh2 yourself with […]




Member Area