Search code examples
phpnet-sshssh2-exec

PHP Net_SSH2 cannot conect


I am trying to use Net_SSH2 class for login in ssh server and i get error:

Notice: No compatible server to client encryption algorithms found in /var/www/html/includes/classes/Net/SSH2.php on line 1389

Code in line 1389 was:

$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:

$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.


Solution

  • I add on top of SSH2.PHP

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

    And login works fine plus error was gone!