*Trying to connect host 1 (windows xp) to host 2(fedora core8)
via SSH and a public key.
*Using Perl Activestate perl 5.10
*I tested first with password auth and was successful.
*Trying to use a putty generated SSH2 -RSA keypair and it fails to connect.
*The only change I have made from working to non working is the auth type, from password to key.
Here is my code - Does anything appear to be wrong here?
#!/usr/bin/perl -w
use strict;
use Net::SSH2;
my $buflen = 100;
my $buf = '0' x $buflen;
my $ssh2 = Net::SSH2->new();
$ssh2->connect('10.1.1.85','22') or die;
#$ssh2->debug(1);
$ssh2->auth_publickey('root','pub.pub','priv.ppk','toor')
or die "Unable to login $! \n";
my $chan1 = $ssh2->channel();
$chan1->blocking(1);
$chan1->exec('df');
$chan1->read($buf, $buflen);
print "BUF: ", $buf, "\n";
$chan1->close;
#my $chan2 = $ssh2->channel();
#$chan2->blocking(1);
#$chan2->exec('echo $HOME');
#$chan2->read($buf, $buflen);
#print "BUF: ", $buf, "\n";
#$chan2->close;
system ("pause");
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.