ssh2_connection for Web service

ssh2_connection for Web service

am 24.03.2010 21:58:36 von Le-shin Wu

--00151747bd94a70a87048292316a
Content-Type: text/plain; charset=ISO-8859-1

I can successfully create a ssh connection within a index.php file by using
ssh2_connect(). But when I try to create a web service by using the same
code, I got "Unable to connect to a.b.c.d (IP address) on port 22" error. In
other words, if I run the command "php index.php" under shell prompt, it
works perfectly; but if I request the same file through my Web browser (
http://mydomain/index.php), I got an unable to connect error. Is there
someone having any idea about that. Thanks a lot for your help. (REHL 5 with
PHP 5.1.6)

--00151747bd94a70a87048292316a--

Re: ssh2_connection for Web service

am 24.03.2010 22:16:19 von vikash.iitb

--000e0cd51dca0842c20482927142
Content-Type: text/plain; charset=UTF-8

It may be a permission problem.

When you try "php index.php", then its 'your-username' is trying to SSH. But
when you run the script through webserver, the user 'apache' is trying to
SSH.

Can you just check this once.

Thanks,
Vikash Kumar
--
http://vika.sh


On Thu, Mar 25, 2010 at 2:28 AM, Le-shin Wu wrote:

> I can successfully create a ssh connection within a index.php file by using
> ssh2_connect(). But when I try to create a web service by using the same
> code, I got "Unable to connect to a.b.c.d (IP address) on port 22" error.
> In
> other words, if I run the command "php index.php" under shell prompt, it
> works perfectly; but if I request the same file through my Web browser (
> http://mydomain/index.php), I got an unable to connect error. Is there
> someone having any idea about that. Thanks a lot for your help. (REHL 5
> with
> PHP 5.1.6)
>

--000e0cd51dca0842c20482927142--

Re: ssh2_connection for Web service

am 25.03.2010 02:57:55 von Le-shin Wu

--0015174c3c34117c5d0482966036
Content-Type: text/plain; charset=ISO-8859-1

Thanks a lot for your advise. In fact, I thought about that as well, but I
do not know how to switch the user from apache to a real user when I send a
request through Web browser. I even tried to use "ssh_rsa" method instead of
password authentication. But I got the same error. Command line fine, but
through web server I got an error in the first place (ssh2_connect). I am
wondering do you have any suggestion. Thanks a lot.

Best

Le-Shin

On Wed, Mar 24, 2010 at 5:16 PM, wrote:

> It may be a permission problem.
>
> When you try "php index.php", then its 'your-username' is trying to SSH.
> But when you run the script through webserver, the user 'apache' is trying
> to SSH.
>
> Can you just check this once.
>
> Thanks,
> Vikash Kumar
> --
> http://vika.sh
>
>
>
> On Thu, Mar 25, 2010 at 2:28 AM, Le-shin Wu wrote:
>
>> I can successfully create a ssh connection within a index.php file by
>> using
>> ssh2_connect(). But when I try to create a web service by using the same
>> code, I got "Unable to connect to a.b.c.d (IP address) on port 22" error.
>> In
>> other words, if I run the command "php index.php" under shell prompt, it
>> works perfectly; but if I request the same file through my Web browser (
>> http://mydomain/index.php), I got an unable to connect error. Is there
>> someone having any idea about that. Thanks a lot for your help. (REHL 5
>> with
>> PHP 5.1.6)
>>
>
>

--0015174c3c34117c5d0482966036--