Forgot to mention ssh2 keys work as they should using the code below.
$connection = ssh2_connect(‘localhost’, 22, array(‘hostkey’=>’ssh-rsa’));
if (ssh2_auth_pubkey_file($connection, ‘abcd’,
‘/home/abcd/.ssh/id_rsa.pub’,
‘/home/abcd/.ssh/id_rsa’, ‘secret’)) {
echo “Public Key Authentication Successful\n”;
} else {
die(‘Public Key Authentication Failed’);
}