Skip Menu |

This queue is for tickets about the Net-SSH-Expect CPAN distribution.

Report information
The Basics
Id: 52267
Status: new
Priority: 0/
Queue: Net-SSH-Expect

People
Owner: Nobody in particular
Requestors: clif [...] eugeneweb.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: BUG? Multiple login attempts don't play well.
Date: Sun, 29 Nov 2009 16:24:33 -0800 (PST)
To: bug-Net-SSH-Expect [...] rt.cpan.org
From: clif [...] eugeneweb.com
Greetings Bruno, I have some machines and accounts where some of them use passwords and some use keys. I try to log in with keys first and then with passwords. Here is the code I've hacked together: my $ssh = Net::SSH::Expect->new ( host => $host, password=> $pass user => 'root', raw_pty => 1, ); LOGIN: { # Try key based Authentication if ($ssh->run_ssh()) { if (($login_output = "Run: " . $ssh->read_all(2)) && ($login_output =~ /Last\s+login:/)) { last LOGIN } $ssh->close(); } # Next try password based login $login_output = "Login: " . $ssh->login(); if ($login_output !~ /Last\s+login:/) { warn "Login to $host has failed. Login output was $login_output"; } } print $login_output; $ssh->close(); } Here is the error I get: SSHAuthenticationError Login timed out. The input stream currently has the contents bellow: at /usr/share/perl5/Expect.pm line 813 Note that the known_hosts file has an old host key listed for the IP address my host is on. This cases run_ssh to fail even though it actually has the proper ssh keys to login. I've solved this by reconstructing $ssh = Net::SSH::Expect->new (...); before the ssh->login, but it would be more intuitive if the ssh->close allowed one to reset everything and start over. Thanks, Clif