I am trying to setup multiple "drones" using Net::SSH::Perl to send a command that creates the work directory, then Net::SCP to copy the files to the drone. The first connection works as intended. The second (a new SSH to the next drone in the list) apparently times out after a 5-10 minute wait. Using debug mode I see the same messages for success and failure - up to the connection closed message:
Setting up drone tux20. tux-queen: Reading configuration data /home/queen/.ssh/config tux-queen: Reading configuration data /etc/ssh_config tux-queen: Connecting to tux20, port 22. tux-queen: Remote version string: SSH-2.0-OpenSSH_4.3p2 Debian-8ubuntu +1 tux-queen: Remote protocol version 2.0, remote software version OpenSS +H_4.3p2 Debian-8ubuntu1 tux-queen: Net::SSH::Perl Version 1.30, protocol version 2.0. tux-queen: No compat match: OpenSSH_4.3p2 Debian-8ubuntu1. tux-queen: Connection established. tux-queen: Sent key-exchange init (KEXINIT), wait response. tux-queen: Algorithms, c->s: 3des-cbc hmac-sha1 none tux-queen: Algorithms, s->c: 3des-cbc hmac-sha1 none tux-queen: Entering Diffie-Hellman Group 1 key exchange. tux-queen: Sent DH public key, waiting for reply. tux-queen: Received host key, type 'ssh-dss'. tux-queen: Host 'tux20' is known and matches the host key. tux-queen: Computing shared secret key. tux-queen: Verifying server signature. tux-queen: Waiting for NEWKEYS message. tux-queen: Enabling incoming encryption/MAC/compression. tux-queen: Send NEWKEYS, enable outgoing encryption/MAC/compression. tux-queen: Sending request for user-authentication service. tux-queen: Service accepted: ssh-userauth. tux-queen: Trying empty user-authentication request. tux-queen: Authentication methods that can continue: publickey,passwor +d. tux-queen: Next method to try is publickey. tux-queen: Trying pubkey authentication with key file '/home/queen/.ss +h/id_dsa' Connection closed by remote host. at /usr/local/share/perl/5.8.7/Net/S +SH/Perl/AuthMgr.pm line 142
Here is the core of the code:
foreach $machine (@machine_name) { $cmd = "$drone_ssh"; { local $ssh; my %params; $params{"protocol"} = '2,1'; $params{"debug"} = '1'; $ssh = Net::SSH::Perl->new( "$machine", %params ); $ssh->login("$drone_user", %params); ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); undef $ssh; } if ( $exit == 0 ) { { # copy run files to drone local $scp; $scp = Net::SCP->new( "$machine", "$drone_user" ); foreach $filename (@files) { chomp( $target = $filename ); $scp->put( "$target", "$base_directory\/$work_directory\/" ) || ( $scp->{errstr} && print( $LF, "ERROR: scp $target to $machine: $scp->{errst +r}" ) ); } undef $scp; } }
I have tried this without the local $ssh , local $scp and undef $ssh and undef $scp commands, with the same results. Why can't I make SSH connections to multiple machines using Net::SSH::Perl?

In reply to Net::SSH::Perl timeout by rbm1213

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.