#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $user = "username"; my $pass = "password"; my $domain = ".mydomain.com"; my $ssh; my $host; my @hosts = qw(host1 host2); my $lscmd = "ls -ltr"; foreach $host (@hosts){ print "$host\n"; $ssh = Net::SSH::Perl->new("$host$domain", protocol => 2, interactive => 0, options => [ "Password Authentication yes" ], (debug=>'true')); $ssh->login($user, $pass); my ($lsout, $lserr, $lsexit) = $ssh->cmd($lscmd); print "lsout = $lsout\n"; print "lserr = $lserr\n"; print "lsexit = $lsexit\n"; } #### .... asmodeus: Net::SSH::Perl Version 1.30, protocol version 2.0. asmodeus: No compat match: OpenSSH_4.2. asmodeus: Connection established. asmodeus: Sent key-exchange init (KEXINIT), wait response. asmodeus: Algorithms, c->s: 3des-cbc hmac-sha1 none asmodeus: Algorithms, s->c: 3des-cbc hmac-sha1 none asmodeus: Entering Diffie-Hellman Group 1 key exchange. asmodeus: Sent DH public key, waiting for reply. asmodeus: Received host key, type 'ssh-dss'. asmodeus: Host 'host2.mydomain.com' is known and matches the host key. asmodeus: Computing shared secret key. asmodeus: Verifying server signature. asmodeus: Waiting for NEWKEYS message. asmodeus: Enabling incoming encryption/MAC/compression. asmodeus: Send NEWKEYS, enable outgoing encryption/MAC/compression. asmodeus: Sending request for user-authentication service. asmodeus: Service accepted: ssh-userauth. asmodeus: Trying empty user-authentication request. asmodeus: Authentication methods that can continue: publickey,keyboard-interactive. asmodeus: Next method to try is publickey. Permission denied at ./ssh_test.pl line 19