#!/usr/bin/perl use Modern::Perl; use Net::SSH::Any; my $hostname = '192.168.247.128'; my $username = 'perl514'; my $password = 'redhat'; my $cmd = 'ls -l'; if (my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password)) { 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"; } else { say "whee...something wrong here" } #### I am connected to 192.168.247.128!!! The files and directories of perl514 on 192.168.247.128 are given below total 16 drwxrwxr-x. 2 perl514 perl514 4096 Nov 14 14:52 perlscripts drwxrwxr-x. 2 perl514 perl514 4096 Nov 14 14:52 test1 drwxrwxr-x. 2 perl514 perl514 4096 Nov 14 14:52 test2 drwxrwxr-x. 2 perl514 perl514 4096 Nov 14 14:52 test3