my $ssh = Net::SSH::Any->new($hostname, user => $user, key_path => "/home/$user/.ssh/id_dsa"); if ($ssh->error) { say "whee...something wrong here: " . $ssh->error; } else { say " I am connected to $hostname!!!"; my @out = $ssh->capture($cmd); say "The files and directories of $username on $hostname are given below"; say "@out"; }