#!perl use strict; use warnings; use Net::OpenSSH::Compat::SSH2; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect('host') or die "Unable to connect to host: $!\n"; $ssh2->auth_password('user', 'password'); my $chan = $ssh2->channel(); $chan->exec("ls"); print while <$chan>; $chan->close; $ssh2->disconnect();