As
moritz has pointed out, ssh generally allows anybody to use it. Since the problem likely lies in a difference in your cli and cgi
environment, one possibility is that your CGI scripts do not have ssh in their PATH. If so, giving the absolute path to ssh would resolve the issue.
In any event, the other bit of advice
moritz gave is also useful. Look at the Apache error log and see if it doesn't just tell you what the problem is.