#!/usr/bin/perl use strict; use warnings; use diagnostics; use Net::SSH::Perl; my $host = 'host'; my $username = 'user'; my $password = 'password'; my $cmd = 'ls -laR /some/directory'; my $ssh = Net::SSH::Perl->new( $host, protocol => '1,2', debug => 1, options => ["KeyRegenerationInterval 1h"] ); $ssh->login( $username, $password ); $ssh->session_id; my ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); print $stdout, "\n";