has pointed out, ssh generally allows anybody to use it. Since the problem likely lies in a difference in your cli and cgi
, 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.
gave is also useful. Look at the Apache error log and see if it doesn't just tell you what the problem is.