#! /usr/bin/perl use strict; use warnings; use 5.020; require Net::SSH2; my %opts = ( debug => 1, trace => -1, ); warn "Net::SSH2 Version: ", Net::SSH2->VERSION, "\n"; my $ssh2 = Net::SSH2->new(%opts); $ssh2->connect('sshserver') or die $ssh2->error(); $ssh2->auth_keyboard( 'benutzer', 'passwort', ) or die $ssh2->error(); my $chan = $ssh2->channel() or die $ssh2->error(); $chan->exec('ls'); print while <$chan>; print "EXIT CODE: ", $chan->exit_status, "\n";