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 testuser@10.0.1.10 '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..
Note that the php exec functions only capture the standard output
stdout, not the error outputstderr. You should redirectstderrtostdoutwhen executing your command, i.e.passthru("ssh ... 2>&1");.