Netmiko: telnet login not reliably working in Netmiko 3.3.2 with recent performance improvements

Created on 12 Oct 2020  路  7Comments  路  Source: ktbyers/netmiko

I am unable to login to a cisco switch using telnet protocol using netmiko 3.3.2, it is throwing AuthenticationException but my credentials seems to be correct as I am able to login using the same credentials using 1.4.0 version of netmiko

Code:

dev = {
     'device_type':'cisco_ios_telnet',
     'host':   'myip',
     'username': 'uuuu',
     'password': 'pppppppp',
     'secret':'pppppp',

conn = ConnectHandler(**dev)
}

Here is the error trace:

Traceback (most recent call last):
  File "nigeria_switch.py", line 12, in <module>
    conn = ConnectHandler(**dev)
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/ssh_dispatcher.py", line 312, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/cisco/cisco_ios.py", line 17, in __init__
    return super().__init__(*args, **kwargs)
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/base_connection.py", line 346, in __init__
    self._open()
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/base_connection.py", line 351, in _open
    self.establish_connection()
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/base_connection.py", line 910, in establish_connection
    self.telnet_login()
  File "/home/sanidhya/Py/email_parsing/env/lib/python3.8/site-packages/netmiko/cisco_base_connection.py", line 171, in telnet_login
    raise NetmikoAuthenticationException(msg)
netmiko.ssh_exception.NetmikoAuthenticationException: Login failed: myip

Additional Information:
python version: Python 3.8.5

bug

Most helpful comment

Just wanted to mention that I was seeing the same thing until fast_cli: False provided a remedy

All 7 comments

Netmiko 1.4.0 is two major releases ago and >3+ years old...it is not really relevant.

Can you enable Netmiko logging and post the log file (for the failing Netmiko 3.3.2 case):

https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel

@ktbyers, Please find below the log dump for both the versions:

Version 3.3.2

DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: 

Version 1.4.0

DEBUG:netmiko:read_channel: 

User Access Verification

Username: 
DEBUG:netmiko:write_channel: b'<username>\r\n'
DEBUG:netmiko:read_channel: in
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: q
Password: 
DEBUG:netmiko:write_channel: b'<password>\r\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: 
% Login invalid

Username: <password>
% Login invalid

Username: 
Username: 
DEBUG:netmiko:write_channel: b'<username>\r\n'
DEBUG:netmiko:read_channel: <username>
Password: 
DEBUG:netmiko:write_channel: b'<password>\r\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel: 
PUBLIC_TEST_SWITCH#
DEBUG:netmiko:read_channel: 
PUBLIC_TEST_SWITCH#
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: 

DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel: PUBLIC_TEST_SWITCH#
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'terminal length 0\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
PUBLIC_TEST_SWITCH#
PUBLIC_TEST_SWITCH#

DEBUG:netmiko:write_channel: b'terminal width 511\n'
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: PUBLIC_TEST_SWITCH#
PUBLIC_TEST_SWITCH#
PUBLIC_TEST_SWITCH#
DEBUG:netmiko:read_channel: 

Note: <password> and <username> contains real values in log but concealed here for security purpose.

Hmmm, try setting fast_cli=False as an argument to ConnectHandler and see if that fixes things?

@ktbyers, it worked with fast_cli=False. Thanks for the suggestion.

Okay, let's leave this open as there is an underlying bug that I need to fix.

Just wanted to mention that I was seeing the same thing until fast_cli: False provided a remedy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dweber42 picture dweber42  路  5Comments

Rooster-OC picture Rooster-OC  路  5Comments

nfordhk picture nfordhk  路  8Comments

Murali24872019 picture Murali24872019  路  6Comments

MichalTaratuta picture MichalTaratuta  路  7Comments