1

I wrote this code:

$host = <My Host>;
$port = 22;
$methods = array('hostkey', 'ssh-rsa');
$username = <My User>;
$pub_key = 'c:\\Users\\MyUser\\AppData\\Roaming\\ssh\\UserKeys\\pub_key.pub';
$prv_key = 'c:\\Users\\MyUser\\AppData\\Roaming\\ssh\\UserKeys\\prv_key';

print "<pre>";
var_export(file_get_contents($pub_key));
print "</pre>";
print "<pre>";
var_export(file_get_contents($prv_key));
print "</pre>";

$connection = ssh2_connect($host, 22, $methods); 
if(ssh2_auth_pubkey_file($connection, $username, $pub_key, $prv_key)){
    echo "Ok!!!!\n";
}else{
    echo "Ko!!!!";
}

When I run the code it returns:

Warning: ssh2_auth_pubkey_file(): Authentication failed for using public key: Callback returned error in....

Can anyone help me to solve this problem?

Dave
  • 5,108
  • 16
  • 30
  • 40
user9846973
  • 57
  • 2
  • 8

0 Answers0