-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi,
Not sure how to address this using netmiko. My goal is to connect to a Cisco cat9k via Telnet. Once connected I have to login, and then enable etc.
Where it's quirky is there are 2 logins;
Into the termserver - this is handled by default connectionHandler
However once logged in then there is another login to the device, this cannot be the same as the login to the terminal server. Sadly not all devices do this so I am thinking of using the find_prompt() to decide next steps.
Any suggestion would be greatly appreciated.
e.g. Connection flow
Escape character is '^]'.
You are logging into a Terminal Server.
This login prompt is authenticating your access using Admin Credentials to the server.
After a successful login you'll be connected to your desired device.
Username:<user>
Password:<password>
You are now connected to the console of your device. Press ENTER to interact.
User Access Verification
Username: <device_user>
Password: <password>
myCat9k#
In my script if the terminal-server telnet login fails then it logs into the ts and clears the line, then tries telnet again..
In an ideal world I could handle the second login manually. However netmiko see's the login, thinks it's the term-server and tries to login using the terminal-server creds. Eventually it fails and the connection is dropped. You can see this in the logs (some noise deleted for brevity)
LOGS::
DEBUG:netmiko:read_channel:
You are logging into a Terminal Server.
This login prompt is authenticating your access using Sandbox Admin Credentials to the server.
After a successful login you'll be connected to your desired device.
Username:
DEBUG:netmiko:write_channel: <username>\r'
DEBUG:netmiko:read_channel: <username>
Password:
DEBUG:netmiko:write_channel: b'********\r'
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
You are now connected to the console of your device. Press ENTER to interact.
DEBUG:netmiko:read_channel:
DEBUG:netmiko:write_channel: b'\r\n'
User Access Verification
Username:
DEBUG:netmiko:write_channel: <username>\r'
DEBUG:netmiko:read_channel: <username>
Password:
DEBUG:netmiko:write_channel: b'********\r'
DEBUG:netmiko:read_channel:
DEBUG:netmiko:write_channel: b'\r\n'
DEBUG:netmiko:read_channel:
% Authentication failed
Username:
DEBUG:netmiko:write_channel: <username>\r'
DEBUG:netmiko:read_channel: <username>
Password:
DEBUG:netmiko:write_channel: b'********\r'Thanks
Mike