I'm building a simple php app, so that I can control my server through a browser.
This is a short version of the app
$user = $_POST['user']; //the username, sent with post-method from form.
$pass = $_POST['pass']; //the password, sent with post-method from form.
$query = $_POST['query']; //the shell command, sent with post-method from form.
Well the problem is that I can't get the response sent from the server. I guess I am using the wrong way of getting it. I've tried a couple of different methods, but I can't get anything.
I know for a fact that the php-ssh2 runs the shell command on the server. But never get any response from the server.. A little frustrating.
02-02-2010, 06:14 PM
Hi, as far as I remember after ssh2_connect(...) you need to call ssh2_fingerprint($ssh) to get ssh server fingerprint before calling ssh2_auth_password(...)
02-03-2010, 04:04 AM
Is your shell command actually outputting anything? If you're just executing a program which does not print anything to stdout then you won't have anything in the stream to read. What happens if you try a 'ls -l' or some other command which definitely outputs results?
02-03-2010, 04:13 AM
Well... The command I'm trying is df -h. And as far as I know that should make an output.
03-07-2010, 11:03 AM
Maybe try phpseclib: a pure php ssh implementation? Unlike the PECL ssh2 extension, phpseclib's author actively provides support, as can be seen by looking at the support forum. Also, frankly, it offers more debugging capabilities than the PECL ssh2 extension does, with such things as $ssh->getLog() and $ssh->getLastError().