[Princeton-pm] Net::SSH::Perl

Vic vhsr00 at yahoo.com
Fri Aug 25 10:54:53 PDT 2006


Hi group,

Have any of you run into any issues like the one I am
having running the Net::SSH::Perl module? I installed
it without any issues following recommendations for
pre-requisites. I turned on debugging, and it is
stopping ssh connection at this point: 
Connection closed by remote host. at
/usr/local/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/AuthMgr.pm
line 43

The script I have is this:

#!/usr/local/bin/perl -w

@F5 = ( 'devicename' );
@ident = ( '/.root/.ssh2/root_system' );
%args = ( port => 22, protocol => 2, identity_files =>
\@ident, debug => 1);
%sftp_args = ( ssh_args => [%args] );
$workdir='/myfiles';

use Net::SSH::Perl;
use Net::SFTP;

foreach $bigip ( @F5 ) {

   my $conn = Net::SSH::Perl -> new(
"$bigip.domain.com", %args );
   $conn -> login('root');
   ( $stdout, $stderr, $exit ) = $conn -> cmd('bigpipe
config save /root/backup/
`hostname`-`date +%m%d%y%H%M`');
#
   print "\$stdout: $stdout!\n\$stderr:
$stderr!\n\$exit: $exit!\n";
   if ( ($stderr =~ m/config save request.../) && (!
$exit ) ) {
      ( $stdout, $stderr, $exit ) = $conn -> cmd('ls
/root/backup');
      chomp $stdout;
      $conn -> cmd('exit');
      my $sftp = Net::SFTP -> new("$bigip.domain.com",
user => 'root', %sftp_ar
gs);
      $sftp -> get("/root/backup/$stdout",
"$workdir/$stdout");
      $sftp -> do_remove("/root/backup/$stdout");
   }
   my %age;
   opendir DIR, "$workdir";
   my @files = grep /$bigip/, readdir DIR;
   closedir DIR;
   my $now = time();
   foreach $file ( @files ) {
      open FILE, "$workdir/$file";
      my $file_age = $now - (stat FILE)[9];
      $age{$file_age} = "$file";
      close FILE;
   }

   my @file_ages = sort { $a <=> $b } keys(%age);
   use File::Compare;
   if ( compare( "$workdir/$age{$file_ages[0]}",
"$workdir/$age{$file_ages[1]}"
) == 0 ) {
      unlink "$workdir/$age{$file_ages[0]}";
   }
   if ( $#files > 6 ) {
      unlink "$workdir/$age{$file_ages[-1]}";
   }


}

====
I copied the public key from my system to device, I
can ssh from command line to device fine using the
keys, but I am having problem automating the process
via the script above. The script works fine on another
system I inherited (do not know what else could have
been modifies, etc). 

BTW, I am new to perl, but very eager to learn more
about it.

Your help is greatly appreciated.

Thanks

Vic

PS. Running Solaris 9 on sparc4 server.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Princeton-pm mailing list