#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my @logins = ( [undef,undef], ["myname","mypass"], ["local","localpw"], ["root",undef], ["root","pass1"], ["root","pass2"], ... ["root","passn] ); my $ssh; while (my $server = ) { chomp $server; print $server; if (SSHConnect($server)) { } } sub SSHConnect { my $server = shift; my $return = 0; $ssh = Net::SSH::Perl->new($server,protocol=>'2,1'); foreach (@logins) { my ($u,$p) = @{$_}; eval { $ssh->login(); }; if (!$@) { $return = 1; last; }; return $return; }