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

Hi, I have created a program using perl CGI where i am calling my server script which is at remote location. For that i have used OpenSSH. But when i run this script from my terminal it works fine my remote machine script also runs properly. But when i do this from Browser it doesn't works. I have used below script.
#!/usr/bin/perl use warnings; use strict; use CGI; use Net::OpenSSH; use warnings; our $cgi = new CGI; use Net::OpenSSH; my %opts = ( user => "UNAME", #password => "MYPASSWORD", strict_mode => 0, ); my $ssh = Net::OpenSSH->new("MY SERVER_IP",%opts,master_opts => [-i => + "MY KEY FILE"], async => 1); $ssh->system("/root/test.sh") or die "remote command failed: " . $ssh->error;
Below are the logs from apache error logs
[Fri Jun 27 12:11:57 2014] [error] [client localhost] Permission denie +d (publickey,gssapi-keyex,gssapi-with-mic).\r, referer: http://localh +ost/cgi-bin1/test.cgi

Replies are listed 'Best First'.
Re: Not able to run remote scipt from perl CGI script
by hippo (Archbishop) on Jun 27, 2014 at 08:39 UTC

    The CGI running user may not have access to the private key (or it may not be where you think it is). To verify, try reading the key file independently in your script before letting Net::OpenSSH at it.

    Please use code tags in future when posting code. Your message above is close to illegible without them. See Markup in the Monastery for details.