#!/usr/bin/perl; use Modern::Perl; use 5.014; use Net::SSH2; my $nasip = '127.0.0.1'; #Actul IP is different. my $user = 'user'; my $pass = 'passwd'; my $ssh = Net::SSH2->new(); $ssh->debug(1); say "Connecting to $nasip"; $ssh->connect("$nasip") || warn "$!"; $ssh->auth_password("$user","$pass"); my $chan = $ssh->channel(); my @output = $chan->exec('nas_server -list'); say "output is: @output"; $chan->close(); #### Connecting to 127.0.0.1 libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type, window_size, packet_size, ((void *)0) , 0 ) -> 0x11353dc output is: 1 Net::SSH2::Channel::DESTROY Net::SSH2::DESTROY object 0x9b745c