foreach $host (@HOSTS) { $ssh = Net::SSH::Perl->new("$host",debug=>1,options => ["ConnectTimeout=5","StrictHostKeyChecking=no"]); $ssh->login($user); ($out, $err, $exit)=$ssh->cmd($exec_cmd); }