netmiko: Netmiko SSH Timeout
I am having issues SSH to a Cisco IOS device. I have tested manual SSH directly from box that I am running the script from with NO issues.
Thanks for any assistance.
#!/usr/bin/env python
from netmiko import ConnectHandler
with open('commands_file') as f:
commands_list = f.read().splitlines()
with open('devices_file') as f:
devices_list = f.read().splitlines()
for devices in devices_list:
print 'Connecting to device" ' + devices
ip_address_of_device = devices_list
ios_device = {
'device_type': 'cisco_ios',
'ip': 'ip_address_of_device',
'username': '',
'password': '',
'secret': ''
}
net_connect = ConnectHandler(**ios_device)
output = net_connect.send_config_set(commands_list)
print output
net_connect = ConnectHandler(**ios_device)
output = net_connect.send_command_expect('test aaa group tacacs+ readonly Temp1234 legacy')
print output
Connecting to device" 10.128.96.37
Traceback (most recent call last):
File "westfieldisescript.py", line 23, in <module>
net_connect = ConnectHandler(**ios_device)
File "/usr/local/lib/python2.7/dist-packages/netmiko/ssh_dispatcher.py", line 131, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 150, in __init__
self.establish_connection()
File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 506, in establish_connection
raise NetMikoTimeoutException(msg)
netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: cisco_ios ip_address_of_device:22
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (7 by maintainers)
I don’t think the way you are creating your array of devices works the way you intend…
results in output that looks like the following…
notice the leading spaces on all but the first “host”, that is why you are getting the underlying
socket.gaierror: [Errno 11001] getaddrinfo failed
error, and subsequentnetmiko.ssh_exception.NetMikoTimeoutException: Connection to device