phpseclib gives me a strange erros

shelly picture shelly · Sep 24, 2015 · Viewed 7.5k times · Source

Im trying to use this, but it just gives me this errors and i have no clue how to fix that..

Warning: include_once(Math/BigInteger.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 891

Warning: include_once(): Failed opening 'Math/BigInteger.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 891

Warning: include_once(Crypt/Random.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 895

Warning: include_once(): Failed opening 'Crypt/Random.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 895

Warning: include_once(Crypt/Hash.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 899

Warning: include_once(): Failed opening 'Crypt/Hash.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 899

Warning: include_once(Crypt/Base.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 904

Warning: include_once(): Failed opening 'Crypt/Base.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 904

Fatal error: Call to undefined function phpseclib_resolve_include_path() in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 1226

include('Net/SSH2.php');
$ssh = new Net_SSH2('host');
if (!$ssh->login('user', 'pass')) {
  echo('Login Failed');
}

$ssh->exec('the cmd line...");
$ssh->disconnect();

Answer

neubert picture neubert · Sep 24, 2015

phpseclib is probably not in your include_path. Quoting phpseclib.sourceforge.net,

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');

include('Net/SSH2.php');
?>

You'll need to adjust that as appropriate. If phpseclib is in the vendor/phpseclib directory then do 'vendor/phpseclib' instead, etc.