douqianmin5367 2018-07-20 23:22
浏览 110

Phpseclib问题 - SSH_MSG_USERAUTH_FAILURE:publickey * PHP

I got some issue using phpseclib,is like my second post, and I've figured it out partially but i can't get it working properly...

Anyway here is the issue: I've installed phpseclib using composer, and I'm using this test script in order to connect to my VPS hosted by amazon, that is giving me some troubles So what I understood is that I need to use the .pem key file in order to authenticate. Easy right?

That's the script:

<?php
include 'vendor/autoload.php';

$loader = new \Composer\Autoload\ClassLoader();
$loader->addPsr4('phpseclib\\', __DIR__ . 'vendor/phpseclib/phpseclib');
$loader->register();

use phpseclib\Crypt\RSA;
use phpseclib\Net\SSH2;

//$key = new Crypt_RSA();
$key = new RSA();
$ret = $key->loadKey(file_get_contents('Key_1.pem'));

if(!$ret){
    echo "loadKey failed
";
    exit;
}

// Domain can be an IP too
$ssh = new SSH2('ip.ip.ip.ip');
if (!$ssh->login('username', $key)) {
    print_r($ssh->errors);
    exit('Login Failed');

}

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

?>

So here is some issues that I'm getting:

1- Crypt_RSA isn't working, Class not found (RSA class doesn't give me any errors) 2- Using RSA I'm getting this error

SSH_MSG_USERAUTH_FAILURE: publickey ) Login Failed

Maybe I'm doing something wrong with the path for the include?

phpseclib is located in:

vendor/phpseclib/phpseclib/phpseclib

Then I've the others folder...

I don't know! Please someone help me out!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)