msk_0984 has asked for the wisdom of the Perl Monks concerning the following question:

Respected monks,

Its great to use Net::SSH2 module which has really made our work easier over Net::SSH::Perl module.

I was working with Net::SSH2 perl module. I wrote a small script that logs into remote systems and fetch its hostname and it went fine.

Now when I have embedded same script in a CGI page, I was giving me the following error in /var/apache/logs/error_logs file

Can't load '/opt/ActivePerl-5.8/site/lib/auto/Net/SSH2/SSH2.so' for mo +dule Net::SSH2: ld.so.1: perl-static: fatal: libcrypto.so.0.9.8: open + failed: No such file or directory at /opt/ActivePerl-5.8/lib/XSLoade +r.pm line 70. at /opt/ActivePerl-5.8/site/lib/Net/SSH2.pm line 467 Compilation failed in require at /var/apache/cgi-bin/ssh_WebAdmin/test +.cgi line 4. BEGIN failed--compilation aborted at /var/apache/cgi-bin/ssh_WebAdmin/ +test.cgi line 4.

All the files ld.so.1 , libcrypto.so.0.9.8 are present in the respective locations. But i dont uderstand what is the problem when I embedded the script in CGI.

Even if I execute and check for any errors by using

$ perl -wc test.cgi test.cgi syntax OK
And when opened in browser I get
Internal Server Error
Please let me know if am doing any thing wrong.

Thanks in advance.


Sushil Kumar

Replies are listed 'Best First'.
Re: Problem with Net::SSH2 when using with CGI programing
by mr_mischief (Monsignor) on Sep 12, 2007 at 19:46 UTC
    This is probably a per-user issue. When you run the program from the command line, are you logged in as the user account for the web server?

    The user that Apache runs under is often 'apache', 'httpd', 'nobody', or 'www'. These are limited-rights accounts that do not have the same environment and file rights as most local users. This is to protect your system, because if a security bug is exploited on your web server, you don't want the code to have many rights.

    Check to see if the files you're having trouble using are readable by the web server's user account. Try 'ps aux | grep apache', 'ps aux | grep httpd', or 'lsof /var/log/httpd/error_log' or similar to see under which account Apache operates.

      Hey

      Thanks very much for your replies. I have checked that one out and tested it out perfectly. Then the script was searching for the libcrypto.so.0.9.8, libgcc_s.so.1 two libraries in /usr/lib which are not available at that location so pasted it. And its working perfectly now.

      Thank You very much for yor reply

      Sushil Kumar