1.11M Members

ssh2_exec is not working

 
0
 

I have script that using to ssh2 to log into the firewall. I would like to run the commands from the firewall as if I was in the terminal when I add in the command in my script I get Resource id #5.

<?php

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

ssh2_auth_password($connection, $user, $pass);

$stream = ssh2_exec($connection, 'get hardware cpu',FALSE);
$check=stream_get_contents($stream);
echo $check;
echo $stream;



?>
LastMitch
Deleted Member
 
2
 

I have script that using to ssh2 to log into the firewall. I would like to run the commands from the firewall as if I was in the terminal when I add in the command in my script I get Resource id #5.

You can't run the command from the terminal by using php?

Who told you that it will work?

It doesn't work like that if you want to work from the terminal then read this:

http://opensuse-guide.org/command.php

If you just have problems connecting ssh2 function read this:

http://www.nusphere.com/kb/phpmanual/function.ssh2-connect.htm

This is how you put the info:

$ssh->connect('your server', 22, 'username', 'somepasswd');

not this:

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

If you still have issue then try this:

On your ini file or httpd.conf do you see these

ssh2.shell 
ssh2.exec 
ssh2.tunnel 
ssh2.scp 
ssh2.sftp

If not restart your Apache

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: