简体   繁体   中英

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!

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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