question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Netmiko | Error: Telnet login failed:

See original GitHub issue

Excuse my indentation, I have this script because my devices have different login credentials-

This script works fine, except when it gets to telnet section, it unable to login to devices, I this on multiple devices but it gives this error Error: Telnet login failed: [ipaddress]

import netmiko
from netmiko import ConnectHandler
from operator import itemgetter
from time import sleep
        try:
            net_connect = ConnectHandler(device_type='cisco_ios_ssh', ip=ip, username=username1, password=password1, secret=password1)
            connection_protocol = 'ssh'
        except:
                        try:
                                net_connect = ConnectHandler(device_type='cisco_ios_ssh', ip=ip, username=username2, password=password2, secret=password2)
                                connection_protocol = 'ssh'
                        except:

                                try:
                                        net_connect =  ConnectHandler(device_type='cisco_ios_telnet', ip=ip, username=username1, password=password1, port=23, verbose=False)
                                        connection_protocol = 'telnet'

                                except Exception as e:
                                        print "Error: " + str(e)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
shrutikapondecommented, Dec 18, 2020

Thanks!! Adding global_delay_factor solved my connection failed issue with napalm.

You could try setting global_delay_factor: 2 (or 4) and see if it makes any difference. This is an argument to ConnectHandler

You would probably need to go into Pdb at about this location:

https://github.com/ktbyers/netmiko/blob/v2.4.2/netmiko/cisco_base_connection.py#L102

I am not seeing on the face of it why Netmiko is not sending the Username (except possibly your device is really slow and hence the global delay factor recommendation).

This is my code snippet:

  from napalm import get_network_driver
  from pprint import pprint
  
  driver = get_network_driver('ios')
  conn_method = {'port': 5036, 'transport': 'telnet', 'global_delay_factor': 2, 'secret': 'nornir'}
  host = '127.0.0.1'
  user = 'nornir'
  passwd = 'nornir'
  
  # With context manager
  with driver(hostname=host, username=user, password=passwd, optional_args=conn_method ) as device:
      print('Getting facts')
      pprint(device.get_facts())
0reactions
carlmontanaricommented, Dec 29, 2019

Going to close this out. If this is still an issue and there is any new information to share feel free to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netmiko telnet login failure issue on some devices
I have a netmiko script that works fine on some IOS devices but fails to login on others. Only commonality is the three...
Read more >
Netmiko Login failure handling - python
I'm trying to write a script to SSH to a device and if authentication failed print out a statement "Login Failed". Unfortunately the...
Read more >
netmiko API documentation - GitHub Pages
Telnet login. Can be username/password or just password. :param pri_prompt_terminator: Primary trailing delimiter for identifying a device prompt. :param ...
Read more >
Module netmiko - Python for network engineers
Inside netmiko uses telnetlib to connect via Telnet. But, at the same time, it provides the same interface for work as for SSH...
Read more >
How to use the netmiko.ssh_exception. ...
To help you get started, we've selected a few netmiko.ssh_exception. ... 'status': 3, 'message': 'Authentication failure - provided credentials rejected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found