We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,820 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

ssh2_exec is not working

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;



?>
2
Contributors
1
Reply
12 Hours
Discussion Span
6 Months Ago
Last Updated
2
Views
tapuwa2002
Junior Poster in Training
56 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 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.

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

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0636 seconds using 2.66MB