从PHP Remotely执行命令shell

时间:2012-07-29 13:18:31

标签: php shell

我试图使用php在我的网页中的远程机器上获取shell的结果。 我使用了这些行:

<?php
$connection = ssh2_connect('192.168.10.10', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, 'whoami');
?>

我试图在Windows机器中获取结果,libssh2已包含在easyphp中。但是同样的信息:

Fatal error: Call to undefined function ssh2_connect() in C:\Program Files (x86)\EasyPHP-5.3.8.0\www\testphp_ssh.php 

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您必须从Microsoft委托下载并安装SSH2的PECL扩展到PHP项目:http://downloads.php.net/pierre/

要查看应用程序和环境配置中的任何错误,请使以下配置指令的值如下所示:

error_reporting = E_ALL|E_STRICT
display_errors = On
short_open_tag = Off
asp_tags = Off
display_startup_errors = On

output_buffering = Off
allow_call_time_pass_reference = Off
zlib.output_compression = Off
track_errors = On
register_globals = Off
session.auto_start = 0
tidy.clean_output = Off

implicit_flush = Off
log_errors = On
ignore_repeated_errors = On
report_memleaks = On