Reputation: 2832
The error I am getting is SSH_MSG_USERAUTH_FAILURE: publickey,gssapi-keyex,gssapi-with-mic
I logged via Putty and generated keys using the following steps
I used the below commands to generate a RSA key and copied the RSA key from there and storied it as id_rsa in a textfile with no extension (I didn't give any passphrases too)
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ec2_user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ec2_user/.ssh/id_rsa.
And here is my php code.when I try to execute it..it saves authentication failed always.Whether I am doing anything wrong here..?
<?php
include('Net/SSH2.php');
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
$rsa->loadKey(file_get_contents('id_rsa'));
$ssh = new Net_SSH2('ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com');
if ($ssh->login('ec2_user', $rsa)) {
echo "Public Key Authentication Successful\n<br />";
} else {
die('Public Key Authentication Failed');
}
echo $ssh->exec("pwd");
?>
Upvotes: 0
Views: 193
Reputation: 97
Why aren't you using the .pem file (key pair) provided to you when you launched the instance?
Upvotes: 0