I've got two issues here. The overall goal here is to have a perl script run 'ps -ef |grep blah blah' on some remote hosts. For most machines, I can use RSH, but for some, I'm stuck with SSH. The kicker is, this is a cgi script so the apache user is the one doing the execution.
I'm using Net::SSH::Perl, but am getting no where. Here's the simple script I've got to test it.
my $ssh = Net::SSH::Perl->new('host');
$ssh->login('user','pass');
my ( $stdout, $stderr, $exit ) = $ssh->cmd('uptime');
print qq(Content-type: text/html
);
print "output from ssh: $stdout\n";
print "error from ssh: $stderr\n";
print "</html>\n";
When I run this through the browser, I get the following error:
mkdir /.ssh: Permission denied at /usr/lib/perl5/vendor_perl/5.8.4/Net
+/SSH/Perl/Util/Hosts.pm line 50
It looks to me as if it's trying to create a .ssh directory in / (which it obviously doesn't have permission to do). /etc/passwd says that apache's homedir is /home/httpd.
EDIT:
The 2nd problem is fixed... the remote machine I was testing with was my little personal romping ground, to which I probably broke last night goofind around w/ the sshd_config.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.