http://www.perlmonks.org?node_id=979596


in reply to Re: Net::SSH2 woes
in thread Net::SSH2 woes

The SSH session is created in Net::SSH2->new(), not $ssh2->connect(). Each SSH session can be used for only one connection, therefore, to connect to a new host, a new SSH session is required. So, you are correct: Net::SSH2->new() must be called for each host, inside the loop.