phpseclib包括破坏回声

时间:2016-06-09 00:30:03

标签: php phpseclib

当我包含phpseclib文件时,我的回声停止工作。我很难安装phpseclib'对'因此,我将其托管在网站目录中并包含在那里。

任何关于为什么回声不再有效的指导将不胜感激。我也没有收到任何错误。

<?php


include("http://website.com/folder/phpseclib1.0.2/Net/SSH2.php");
set_include_path('http://website.com/folder/phpseclib1.0.2');

$ssh = new Net_SSH2('000.000.000.000');

if (!$ssh->login('user', 'pass')) {
        exit('Login Failed');
        }

echo $ssh->exec('cd /home/cpaneluser/public_html/folder');
echo $ssh->exec('openssl smime -sign -signer newcertificate.pem -inkey key.pem -nodetach -outform der -in unsigned.txt -out signed.txt');
echo $ssh->exec('chmod user:user signed.txt');
echo $ssh->read();

echo '<pre>';
var_dump($ssh);
echo '</pre>';

?>

1 个答案:

答案 0 :(得分:0)

也许只需将phpseclib放在/ var / lib / php / phpseclib或其他内容中然后执行set_include_path(get_include_path() . PATH_SEPARATOR . '/var/lib/php/phpseclib');。或者您可以使用Composer安装它。

无论如何,安装在一边......

echo $ssh->exec('cd /home/cpaneluser/public_html/folder');
echo $ssh->exec('openssl smime -sign -signer newcertificate.pem -inkey key.pem -nodetach -outform der -in unsigned.txt -out signed.txt');
echo $ssh->exec('chmod user:user signed.txt');
echo $ssh->read();

那不行。你可以更改目录,但是当你运行openssl命令时,你将会回到起始目录 - 而不是你要进入的目录。有关原因的说明,请参阅http://phpseclib.sourceforge.net/ssh/examples.html#chdir$ssh->read()只有在交互式shell中使用它时才会执行任何操作(例如,您已完成$ssh->write())或enabled a PTY。我的建议:这样做:

$commands = [];
$command[] = 'cd /home/cpaneluser/public_html/folder';
$command[] = 'openssl smime -sign -signer newcertificate.pem -inkey key.pem -nodetach -outform der -in unsigned.txt -out signed.txt';
$command[] = 'chmod user:user signed.txt';
echo $ssh->exec(implode('; ', $command));