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;



?>
Member Avatar for LastMitch

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.