my $ssh = Net::OpenSSH->new("$username:$password\@$ip", timeout => 30); $ssh->error and die "unable to connect to remote host: ". $ssh->error; my @ls = $ssh->capture("ls"); $ssh->error and die "remote ls command failed: " . $ssh->error;