in reply to Execute a perl script from PHP?

G'day jtzako,

"ssh: illegal option -- M"

This sounds like a pathing issue. You have code somewhere that's expecting ssh to have an M option; however, the version of ssh that's been found (using PHP) has no such option. Presumably, your command line version, does have an M option.

From your update:

"If I run the script manually using my own login it works. However if I try to sudo -su to the web server's username it never connects ..."

That's a bit more evidence in favour of a pathing problem. Here's the type of thing that I think's happening:

$ which ssh /opt/local/bin/ssh $ ssh -V OpenSSH_5.9p1, OpenSSL 1.0.0e 6 Sep 2011 $ echo $PATH ...:/opt/local/bin:...:/usr/bin:... $ sudo su - Password: # which ssh /usr/bin/ssh # ssh -V OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 # echo $PATH ...:/usr/bin:...
"... the error_log I see some errors ..."

This is a good place to look when troubleshooting; another is access_log (see Log Files). You might also consider temporarily changing the LogLevel for more verbose feedback.

See also: Environment Variables in Apache; Apache Module mod_ssl; Apache HTTP Server Documentation.

— Ken