我正在使用php phpseclib。执行脚本时出现以下错误
PHP Fatal error: Class 'Crypt_RSA' not found
in /home/xxxxx/public_html/index.php on line 5
PHP SCRIPT
<?php
include('library/php/Net/SSH2.php');
$key = new Crypt_RSA();
$key->setPassword('891600909v');
$key->loadKey(file_get_contents('891600909'));<--This is the pvt key file in home directory in my ubuntu PC-->
$ssh = new Net_SSH2('www.xxxxx.com');
if (!$ssh->login('xxxxx.com', $key)) {
exit('Login Failed');
}
echo $ssh->read('xxxxx.com@xxxxx.com:~$');
$ssh->write("ls -la\n");
echo $ssh->read('xxxxx.com@xxxxx.com:~$');
?>
我怎么能解决这个问题?
答案 0 :(得分:5)
您还需要包含Crypt_RSA类的RSA.php文件。
在其他包含下添加此内容(假设您已下载此文件):
include('library/php/Crypt/RSA.php');
答案 1 :(得分:2)
添加到Ryan Kempt所说的内容,确保正确设置了include_path。例如
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
答案 2 :(得分:0)