AKS
AKS

Reputation: 31

Connecting PHP to SFTP using phpseclib

I need to connect to a SFTP server to upload files using PHP (PHP version: 5.3.13).

I'm trying to use phpseclib but I get the following error:

Notice: No compatible server to client encryption algorithms found in [...]\phpseclib1.0.2\Net\SSH2.php on line 1375 Login Failed

The code I'm using is:

    include(CfgPath .'/phpseclib1.0.2/Net/SFTP.php');
    include(CfgPath .'/phpseclib1.0.2/Crypt/Random.php');
    $port = 22;
    $sftp = new Net_SFTP($host, $port);
    if (!$sftp->login($user, $pass)) {
        exit('Login Failed');
    } else { echo 'Sucess'; }

Any idea of what might be causing this problem and how to solve it? Thank you!

Upvotes: 1

Views: 2535

Answers (2)

Player1
Player1

Reputation: 3166

I added this line above all the line

set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib1.0.2');

The PHP file is looking for a plugin which can be found at \xampp\php\PEAR for client encryption.

Upvotes: 0

AKS
AKS

Reputation: 31

Adding this at the top set_include_path(CfgPath .'/phpseclib1.0.2/'); like Denis Alimov suggested solved it. Thank you!

Upvotes: 2

Related Questions