Hey guys,

I've got a simple engine which forks and attempts to make simaltaneous ssh connections to various (and different) hosts.

To do this, I'm using Parallel::ForkManager and the Net::SSH::Perl module.

My problem is that if I attempt to make these ssh connections in parallel/simaltaneously, then they are always unsuccessful.

With debug mode on, Net::SSH::Perl outputs

Verifying server signature. Waiting for NEWKEYS message. Enabling incoming encryption/MAC/compression. Send NEWKEYS, enable outgoing encryption/MAC/compression. Sending request for user-authentication service.

before croaking with the message:

Connection closed by remote host. at /usr/lib/perl5/site_perl/5.8.0/Ne +t/SSH/Perl/AuthMgr.pm line 43

Yet if I make my engine make these connections in a 'one at a time' fashion by setting Parallel:ForkManagers max probes setting to 1, then they always connect in succession without a problem.

My code for an ssh connection is very simple.

#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $sshusername = "anthski"; my $sshpasswd = "somepassword"; my $host = "192.168.0.1"; my $command = "date"; my $ssh = Net::SSH::Perl->new($host, debug => 1, protocol => 2); my $loginStatus = $ssh->login($sshusername,$sshpasswd); my $stdout; my $stderr; my $exit; eval { ($stdout,$stderr,$exit) = $ssh->cmd($command); }; if ($@) { if ($@ =~ m/Permission denied/i) { print "Authentication failed\n"; exit 1; } } print "$stdout\n";

The remote servers are a mix of solaris and redhat boxes (7.3 and AS4). All the connections work by hand as well as when run individually.

Has anyone ran into a similar problem? Anyone with any gotchas to share about Net::SSH::Perl and simaltaneous connections, or any advice (which may be non-Perl orientated) about why these connections may fail? Perhaps there's some ssh_config option that I need to pass...

cheers,
Anth


In reply to Net::SSH::Perl and simaltaneous connections by anthski

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.