Skip to content

Pointless 10 second login delay when using SSH keys #19

Closed
@toreanderson

Description

@toreanderson

When logging in to a router using SSH keys (either with passphrase-less keys or with an SSH agent), Net::Netconf::Device->new() consistently takes 10 seconds to return a logged-in object. The reason is the following code at in Net::Netconf::Access::ssh:

# Send our password or passphrase
if ($ssh->expect(10, 'password:', 'Password:', '(yes/no)?', '-re', 'passphrase.*:')) {

(see https://github.com/Juniper/netconf-perl/blob/master/lib/Net/Netconf/Access/ssh.pm#L68)

The problem is that when you're using SSH keys, you will never be prompted for a password. Hence that 10 second timeout will happen every time. When attempting to manage a large number of devices in serial, this significantly lengthens the runtime of automation scripts.

IMHO, the best way to deal with this issue is to get rid of all the Expect crap and instead use an Perl implementation of SSH. (The best one available is probably Net::SSH2.) For what it's worth, I wrote a quick proof of concept Net::Netconf::Access subclass using Net::SSH::Perl::Subsystem::Client. I only required 48 lines of code (compared to the 134 in ssh.pm), so it got way simpler and much more robust than anything using Expect possibly can. And it doesn't have the 10 second login delay, of course. Let me know if you're interested in having a look at this, and I can send you a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions