E
E
Evgeny Elizarov2013-03-06 10:38:52
linux
Evgeny Elizarov, 2013-03-06 10:38:52

Can't login via ssh and execute command from php

There is a server with nginx + php-fpm, there is a simple page that does something like

<?php
$uname = `ssh -i /var/www/.ssh/id_rsa [email protected]192.168.11.1 uname -a | awk '{print $3}'`;
echo $uname;
?>

And so at start from a browser I receive kukish. If I log in as the nginx user through the console and execute the command, everything is fine:
[email protected] ~ $ ssh -i /var/www/.ssh/id_rsa [email protected] uname -a | awk '{print $3}'
3.8.1 - gentoo

Also, if you run these pages from the console under the nginx user, everything is fine too:
[email protected] ~ $ php /home/share/www/www/index.php
3.8.1-gentoo


What can be a joint-sir? It worked without problems with Apache, but somehow it doesn’t take off with the transition to nginx.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2013-03-06
@KorP

Are you sure that php is being executed by the nginx user?
PS: maybe not php-ftp, but fpm?

S
Sergey Venediktov, 2013-03-06
@sven

Try to specify the full paths to the running utilities. Perhaps the environment variables are not being passed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question