Re: Problem with SSH output when called from apache
| From: | Rasmus Lerdorf | Date: | Tue, 07 Sep 2004 01:29:55 +0000 |
| Subject: | Re: Problem with SSH output when called from apache | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196004@lists.php.net to get a copy of this message | ||
On Mon, 6 Sep 2004, Chandu Nannapaneni wrote:
> I want to capture the output of a certain remote command ( issued
> thru a SSH session to a remote server) in PHP.
>
> The following code is working well when ran from the console
> Ex: php -q test.php
>
> <?
> passthru("/usr/bin/ssh -v -i /var/wwwhtml/sshtest/id_rsa
> test@remotemachine uptime");
> ?>
>
> But when called from apache .. It's not giving any ouput.
>
> test@remotemachine is well configured for ssh without passphrase
> I've checked the file permissions of /var/wwwhtml/sshtest/id_rsa
> It's given read permissions for the user 'apache' ( apache is running
> as apache:apache )
>
> Any hints ???
But have you tested this as user apache from the command line?
su - apache
/usr/bin/ssh -v -i /var/wwwhtml/sshtest/id_rsa test@remotemachine uptime
Chances are you will also need to add -o "BatchMode yes" to that ssh
command.
-Rasmus