SSHing from PHP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sprintf
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:56 pm

SSHing from PHP code

Post by sprintf »

please help me,

i have a php script that invokes a bash script on a remote machine via ssh. both the machines have ssh access. when i invoke the php script from the browser it doesnt get executed but when i invoke that script from command line through php interpreter it works. i dont understand why it isnt working. please help


thax
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: SSHing from PHP code

Post by Christopher »

What function does it use to "invoke" the script?
(#10850)
sprintf
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:56 pm

Re: SSHing from PHP code

Post by sprintf »

i have tried both exec and system
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: SSHing from PHP code

Post by Christopher »

It sounds like your user account can run ssh, but the user under which the webserver runs does not. It may be that you just need to su to that account and ssh to the desired server so that ssh will create an entry for the target server.
(#10850)
sprintf
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:56 pm

Re: SSHing from PHP code [RESOLVED]

Post by sprintf »

thanks, it WAS as you suggested, permission issue. ALL working
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: SSHing from PHP code

Post by Chris Corbyn »

There are a bunch of SSH related functions by the way ;) You'll have to install the appropriate extension for them to work however.

http://au2.php.net/manual/en/book.ssh2.php
Post Reply