use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->debug(1); $ssh2->connect('machine') or die " Cannot connect to 219 "; $ssh2->auth_password('username','password') or die " username/password is wrong "; print "Username/Password is correct\n"; my $chan2 = $ssh2->channel(); $chan2->shell(); print $chan2 "hostname -a\n"; print "LINE : $_" while <$chan2>; $chan2->close;