Don't just guess, look at the log files. If you coded your program correctly it will give you a nice, informative error message telling you what went wrong. If not, go fix your script.
On my linux box ssh has permissions 755, which means that everybody, including apache, can use it. If you happen to have selinux installed and enabled that might be different, though.