0

I was trying to get result from shell in a remote machine in my web page using php. I used these lines:

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

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

I am trying to get result in my web page in windows machine and libssh2 is already included in easyphp . but the same message:

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

Any idea?

Mas
  • 111
  • 1
  • 3
  • 7
  • Possible duplicate of: http://stackoverflow.com/questions/4686091/how-can-i-execute-remote-commands-in-php-via-ssh – Leri Jul 29 '12 at 13:25

1 Answers1

1

You have to download and install the PECL extension for SSH2 from the Microsoft delegate to the PHP project: http://downloads.php.net/pierre/.

To see any errors in your applications and in the configuration of your environment, make the values of the following configuration directives look like this:

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
Flavius
  • 13,566
  • 13
  • 80
  • 126
  • Thanks for response, I have downloaded the php_ssh2-0.11.2-5.3-vc9-x86.zip and extracted to the ext folder in php. Then added to php.ini, I have restarted easyphp but still the same error message – Mas Jul 29 '12 at 13:33
  • Make sure you use `php.ini-development` (rename it to `php.ini`). You should aspire at becoming a professional, and professionals don't use "easyphp" or similar do-nothing understand-nothing approaches. Learn how it works by installing and configuring apache and PHP individually: http://news.softpedia.com/news/Manually-configure-PHP5-and-Apache2-62975.shtml. If you do it properly, PHP will at least give you hints on what is wrong. – Flavius Jul 29 '12 at 13:37
  • I have already php.ini file. I don't see the reason to install everything manually, I want just to run a command shell remotely from php. – Mas Jul 29 '12 at 13:44
  • As I said: Make sure you use `php.ini-development` (rename it to `php.ini`), and PHP will at least give you hints on what could be wrong. – Flavius Jul 29 '12 at 13:51
  • See my edited answer. You should however really aspire at becoming a professional, who never says "but I don't want to learn, I want to get it work". The reality is: you get it working WITH KNOWLEDGE. – Flavius Jul 29 '12 at 14:03
  • Thanks for response ..In fact, I did not mean not to learn but I want to say not to waste time on such things..this is a part of project management you should know and take a tip: if you spend more than you expect change the wave ;-)...thanks for response and you had added I have tested before 2 days on the same error message..I saw the log files end error reporting...sometimes knowledge is not enough to make things workable...fine – Mas Jul 29 '12 at 14:17