From: bsingh on
I get the following error even though it is clearly connecting. Any
amount of timeout is not helping.
How do I avoid this exception? Thank you.

SSHAuthenticationError Login timed out. The input stream currently has
the contents bellow: Last login: Fri Jan 8 20:20:46 2010 from
gildb118.flowserve.net
at /cygdrive/c/Data/perl_mods/lib/Expect.pm line 828
at /cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 209
Net::SSH::Expect::__ANON__[/cygdrive/c/Data/perl_mods/lib/Net/
SSH/Expect.pm:212]('ARRAY(0x10530758)') called at /cygdrive/c/Data/
perl_mods/lib/Expect.pm line 828
Expect::_multi_expect(1, 'ARRAY(0x105308d8)', 'ARRAY
(0x10530ae8)') called at /cygdrive/c/Data/perl_mods/lib/Expect.pm line
565
Expect::expect('Expect=GLOB(0x10576940)', 1, 'ARRAY
(0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY(0x10530338)', 'ARRAY
(0x10530458)', 'ARRAY(0x10530590)') called at /cygdrive/c/Data/
perl_mods/lib/Net/SSH/Expect.pm line 580
Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH
(0x10517c08)', 1, 'ARRAY(0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY
(0x10530338)', 'ARRAY(0x10530458)', 'ARRAY(0x10530590)') called at /
cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 213
Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x10517c08)')
called at netsshexpect.pl line 13

Here's the code
------------------------------------------
use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new (
host => $host,
password=> $pwd,
user => $usr,
raw_pty => 1,
timeout => 10
);

my $login_output = $ssh->login();


# disable terminal translations and echo on the SSH server
# executing on the server the stty command:
$ssh->exec("stty raw -echo");


my $cmd = "ls -l";
my $cmd_out;

$cmd_out = $ssh->exec($cmd);

print "\n";
From: C.DeRykus on
On Jan 8, 3:18 pm, bsingh <bsinghr...(a)gmail.com> wrote:
> I get the following error even though it is clearly connecting. Any
> amount of timeout is not helping.
> How do I avoid this exception? Thank you.
>
> SSHAuthenticationError Login timed out. The input stream currently has
> the contents bellow: Last login: Fri Jan  8 20:20:46 2010 from
> gildb118.flowserve.net
>  at /cygdrive/c/Data/perl_mods/lib/Expect.pm line 828
>  at /cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 209
>         Net::SSH::Expect::__ANON__[/cygdrive/c/Data/perl_mods/lib/Net/
> SSH/Expect.pm:212]('ARRAY(0x10530758)') called at /cygdrive/c/Data/
> perl_mods/lib/Expect.pm line 828
>         Expect::_multi_expect(1, 'ARRAY(0x105308d8)', 'ARRAY
> (0x10530ae8)') called at /cygdrive/c/Data/perl_mods/lib/Expect.pm line
> 565
>         Expect::expect('Expect=GLOB(0x10576940)', 1, 'ARRAY
> (0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY(0x10530338)', 'ARRAY
> (0x10530458)', 'ARRAY(0x10530590)') called at /cygdrive/c/Data/
> perl_mods/lib/Net/SSH/Expect.pm line 580
>         Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH
> (0x10517c08)', 1, 'ARRAY(0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY
> (0x10530338)', 'ARRAY(0x10530458)', 'ARRAY(0x10530590)') called at /
> cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 213
>         Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x10517c08)')
> called at netsshexpect.pl line 13
>
> Here's the code
> ------------------------------------------
> use Net::SSH::Expect;
>
> my $ssh = Net::SSH::Expect->new (
>             host => $host,
>             password=> $pwd,
>             user => $usr,
>             raw_pty => 1,
>             timeout => 10
>         );
>
> my $login_output = $ssh->login();


The Net::SSH::Expect doc shows a keyword search on the
login() output:

if ($login_output !~ /Welcome/) {
die "Login has failed....";
}

Did you forget to do that?


> ...

--
Charles DeRykus
From: C.DeRykus on
On Jan 9, 3:08 pm, "C.DeRykus" <dery...(a)gmail.com> wrote:
> On Jan 8, 3:18 pm, bsingh <bsinghr...(a)gmail.com> wrote:
>
>
>
> > I get the following error even though it is clearly connecting. Any
> > amount of timeout is not helping.
> > How do I avoid this exception? Thank you.
>
> > SSHAuthenticationError Login timed out. The input stream currently has
> > the contents bellow: Last login: Fri Jan  8 20:20:46 2010 from
> > gildb118.flowserve.net
> >  at /cygdrive/c/Data/perl_mods/lib/Expect.pm line 828
> >  at /cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 209
> >         Net::SSH::Expect::__ANON__[/cygdrive/c/Data/perl_mods/lib/Net/
> > SSH/Expect.pm:212]('ARRAY(0x10530758)') called at /cygdrive/c/Data/
> > perl_mods/lib/Expect.pm line 828
> >         Expect::_multi_expect(1, 'ARRAY(0x105308d8)', 'ARRAY
> > (0x10530ae8)') called at /cygdrive/c/Data/perl_mods/lib/Expect.pm line
> > 565
> >         Expect::expect('Expect=GLOB(0x10576940)', 1, 'ARRAY
> > (0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY(0x10530338)', 'ARRAY
> > (0x10530458)', 'ARRAY(0x10530590)') called at /cygdrive/c/Data/
> > perl_mods/lib/Net/SSH/Expect.pm line 580
> >         Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH
> > (0x10517c08)', 1, 'ARRAY(0x105776c0)', 'ARRAY(0x10530218)', 'ARRAY
> > (0x10530338)', 'ARRAY(0x10530458)', 'ARRAY(0x10530590)') called at /
> > cygdrive/c/Data/perl_mods/lib/Net/SSH/Expect.pm line 213
> >         Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x10517c08)')
> > called at netsshexpect.pl line 13
>
> > Here's the code
> > ------------------------------------------
> > use Net::SSH::Expect;
>
> > my $ssh = Net::SSH::Expect->new (
> >            host => $host,
> >             password=> $pwd,
> >             user => $usr,
> >             raw_pty => 1 ho,
> >             timeout => 10
> >         );
>
> > my $login_output = $ssh->login();
>
> The Net::SSH::Expect doc shows a keyword search on the
> login() output:
>
>         if ($login_output !~ /Welcome/) {
>             die "Login has failed....";
>         }
>
> Did you forget to do that?
>
> > ...
>

Also, I haven't used Net::SSH::Expect but setting the
ssh verbose option might provide some info about where
the login transaction fails or times out.


my $ssh = Net::SSH::Expect->new (
host => $host,
password=> $pwd,
user => $usr,
ssh_option => "-v -v -v",
...

There are also some expect debug settings that may
be useful at some point.

--
Charles DeRykus