tags:

views:

43

answers:

1

Hi Everyone,

I can't seem to execute the ssh command from any of the PHP functions like exec, system, passthru etc..

I've even tried /bin/ssh however no output is displayed

Any ideas? I can confirm that by doing "su - www-data" and then trying ssh works, meaning that the apache user has access to ssh..

Thanks

Update: Sorry everything, it appears that ssh is being run ok, it's the remote commands that arn't running. Example:

$remote_command = "/usr/bin/ssh -i /home/www-data/id_rsa [email protected] 'echo hi > /home/testuser/test'"; passthru($remote_command);

I am seeing traffic on the remote server, however the new file "test" isn't being created..

A: 

Note that the php exec functions only capture the standard output stdout, not the error output stderr. You should redirect stderr to stdout when executing your command, i.e. passthru("ssh ... 2>&1");.

cweiske
Thanks! Now I can see that I have a key issue :) Nothing to do with PHP...
jtnire
then please accept the answer.
cweiske
Sorry about the delay in accepting the answer. It said I had to wait 5 minutes
jtnire
sorry for my impatience, but your 40% accept rate was a bit disturbing for me :)
cweiske