#instead of if($ssh2-> auth_password('user', 'pass')){ print "ok"; my $chan2 = $ssh2-> channel(); $ssh2-> ($chan2); #what is this step? print $chan2 "uname\n"; #try it without the if block $ssh2->auth_password('user','pass') or die "Unable to login $@ \n"; my $chan = $ssh2->channel(); $chan->blocking(0); $chan->exec('ls -la'); while (<$chan>){ print } #$chan->close;