my @hosts = qw(foo1.bar.com foo2.bar.com ...); for (@hosts) { system "ssh $_ -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no true" }