anthski has asked for the wisdom of the Perl Monks concerning the following question:
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.
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH::Perl and simaltaneous connections
by eXile (Priest) on Aug 25, 2005 at 04:52 UTC | |
by anthski (Scribe) on Sep 02, 2005 at 01:47 UTC | |
|
Re: Net::SSH::Perl and simaltaneous connections
by sk (Curate) on Aug 25, 2005 at 03:33 UTC | |
by anthski (Scribe) on Aug 25, 2005 at 03:56 UTC | |
by sk (Curate) on Aug 25, 2005 at 05:34 UTC | |
by Anonymous Monk on Sep 29, 2014 at 20:29 UTC |