#!/usr/bin/perl use Modern::Perl; use Net::SSH::Any; my $hostname = '192.168.247.128'; my $username = 'perl514'; my $password = 'redhat'; say "Trying to connect to $hostname . Might take a while"; my $ssh = Net::SSH::Any->new($hostname, user => $username, key_path => "/home/$username/.ssh/id_dsa"); if ($ssh->error) { say "whee...something wrong here: " . $ssh->error; } else { say " I am connected to $hostname!!!"; my @out = $ssh->capture("ls -la"); say "The files and directories of $username on $hostname are given below"; say "@out"; }