Description
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.*:')) {
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.