http://www.perlmonks.org?node_id=683683


in reply to Module Net::SSH::Expect - Cannot interact

First, you may have better luck using Net::SSH2. However, if for some reason you must use SSH1, it appears that you are using a passwordless login (implying that you are using trusted keys to login), but you said that you can not set up trusted hosts. Try using the example segment below from the Net::SSH::Expect docs for logging in with a password (includes error checking).
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; # # You can do SSH authentication with user-password or without +it. # # Making an ssh connection with user-password authentication # 1) construct the object my $ssh = Net::SSH::Expect->new ( host => "myserver.com", password=> 'pass87word', user => 'bnegrao', raw_pty => 1 ); # 2) logon to the SSH server using those credentials. # test the login output to make sure we had success my $login_output = $ssh->login(); if ($login_output !~ /Welcome/) { die "Login has failed. Login output was $login_output"; }

Replies are listed 'Best First'.
Net::SSH::Expect::Expect - Cannot interact - Followup
by phillipewu (Initiate) on Apr 30, 2008 at 23:12 UTC
    Sorry there seems to be a misunderstanding.

    The login part works fine.
    However when I run $exp->interact I am expecting that I will have an interactive session but I cannot type (human) anything into that window.

    Please, any ideas how to fix this?
      This worked for me:

      #!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new( host => 'localhost', user => 'someuser', password => 'somepassword' ); warn "Starting SSH..."; $ssh->run_ssh(); warn "Testing login output..."; my $login_output = $ssh->login(); print " Done", "\n"; my $who = $ssh->exec('who'); print($who); my $exp = 'who'; $exp = $ssh->get_expect(); $exp->interact();

      I guess that my system works fine without disabling the terminal. It may or may not work for you.