简体   繁体   English

PHP Net_SSH2 无法连接

[英]PHP Net_SSH2 cannot conect

I am trying to use Net_SSH2 class for login in ssh server and i get error:我正在尝试使用 Net_SSH2 类在 ssh 服务器中登录,但出现错误:

Notice : No compatible server to client encryption algorithms found in /var/www/html/includes/classes/Net/SSH2.php on line 1389注意:在第1389行的/var/www/html/includes/classes/Net/SSH2.php 中找不到兼容的服务器到客户端加密算法

Code in line 1389 was:第 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);
        }

My PHP file for process:我的进程 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');

PS.附注。 -> i also get Login Failed, but my login was OK i try true terminal on web server its works fine. -> 我也登录失败,但我的登录没问题,我在网络服务器上尝试真正的终端,它工作正常。

Question is why the login fail bat my data was correct and how fix error.问题是为什么登录失败我的数据是正确的以及如何修复错误。

I add on top of SSH2.PHP我在 SSH2.PHP 之上添加

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

And login works fine plus error was gone!登录工作正常,错误消失了!

some one can add for php7 , ultimately it is resolved on Ubuntu 16.04.有人可以为 php7 添加,最终在 Ubuntu 16.04 上解决。

by adding two lines in my code通过在我的代码中添加两行

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