[英]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.