use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => "utility", user => 'vzblk0', raw_pty => 1 ); # Start the ssh process $ssh->run_ssh() or die "SSH process couldn't start: $!"; # you should be logged on now. Test if you received the remote prompt: $output=$ssh->read_all(2); print($output); if ($output =~ />\s*\z/) {die "where's the remote prompt?"}; # - now you know you're logged in - # # disable terminal translations and echo on the SSH server # executing on the server the stty command: $ssh->exec("stty raw -echo"); $output = $ssh->exec("who"); print ($output); $output = $ssh->exec("uname -a"); print ($output); $exp=$ssh->get_expect(); $exp->interact;