繁体   English   中英

PHP Net_SSH2 无法连接

[英]PHP Net_SSH2 cannot conect

我正在尝试使用 Net_SSH2 类在 ssh 服务器中登录,但出现错误:

注意:在第1389行的/var/www/html/includes/classes/Net/SSH2.php 中找不到兼容的服务器到客户端加密算法

第 1389 行的代码是:

$decrypt = $this->_array_intersect_first($encryption_algorithms, $this->encryption_algorithms_server_to_client);
        $decryptKeyLength = $this->_encryption_algorithm_to_key_size($decrypt);
        if ($decryptKeyLength === null) {
            user_error('No compatible server to client encryption algorithms found');
            return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
        }

我的进程 PHP 文件:

$ssh = new Net_SSH2('192.168.111.159');
if (!$ssh->login('root', 'xxxxxxx')) {
    exit('Login Failed');
}

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

附注。 -> 我也登录失败,但我的登录没问题,我在网络服务器上尝试真正的终端,它工作正常。

问题是为什么登录失败我的数据是正确的以及如何修复错误。

我在 SSH2.PHP 之上添加

set_include_path('includes/classes/Net/'); 

登录工作正常,错误消失了!

有人可以为 php7 添加,最终在 Ubuntu 16.04 上解决。

通过在我的代码中添加两行

set_include_path('/usr/share/php/phpseclib/');
include('Net/SSH2.php');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM