Jump to content

ssh2_exec() problem...


apol

Recommended Posts

Hi list,

 

I have installed libssh2 on my apache2 server.

I have written this script:

 

<?php

 

 

$connection = ssh2_connect('10.0.0.10', 22);

 

if (ssh2_auth_password($connection, 'admin', 'apolyxrono')) {

  echo "Authentication Successful!\n";

}

else {

  die('Authentication Failed...');

}

 

if(!($stream=ssh2_exec($connection, 'configure')))

echo "<br>configure-false";

?>

 

end always it prints:

Authentication Successful!

configure-false'

 

....What am i doing wrong?

 

I don 't know a lot from ssh

 

thanks a lot

Link to comment
https://forums.phpfreaks.com/topic/46355-ssh2_exec-problem/
Share on other sites

The command  may not finish before the function return if the stream is not set to blocking mode. You may have to set the stream to blocking mode in order to get any output from the command.

Quote from a comment on the ssh2_exec() page from php.net

 

http://us.php.net/manual/en/function.ssh2-exec.php

 

As for the command itself, I haven't really messed around with *nix too much.  Are you sure there is actually something to configure?  Maybe you should cd to a directory first and try again?

Link to comment
https://forums.phpfreaks.com/topic/46355-ssh2_exec-problem/#findComment-225526
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.