Open mvmahadevan opened 2 years ago
Can you show me the error or exception that you receive?
Greetings Kirk, here is the error.
(py-3.9.7) [xxxxxxxxxxxxxxxxxx ~]$ python cisco_netmiko_show.py
Welcome to Python Scripting !!!
Enter the username: xxxxxxxxxx
Enter the password:
Traceback (most recent call last):
File "/home/g706361/py-3.9.7/lib64/python3.9/site-packages/netmiko/base_connection.py", line 1046, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "/home/g706361/py-3.9.7/lib64/python3.9/site-packages/paramiko/client.py", line 349, in connect
retry_on_signal(lambda: sock.connect(addr))
File "/home/g706361/py-3.9.7/lib64/python3.9/site-packages/paramiko/util.py", line 279, in retry_on_signal
return function()
File "/home/g706361/py-3.9.7/lib64/python3.9/site-packages/paramiko/client.py", line 349, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/g706361/cisco_netmiko_show.py", line 26, in
Common causes of this problem are:
Device settings: cisco_ios xx.xx.xx.xx:22
Hey, i was connecting to a cisco devices with the below script, but unfortunately the script stops if the devices is login for the first time. The script works after i have login manually to the device.
Script: cisco_netmiko_show.py from netmiko import ConnectHandler import getpass
with open('devices.txt') as f: devices = f.read().splitlines()
device_list = list()
username = input('Enter the username: ') password = getpass.getpass('Enter the password: ')
for ip in devices: cisco_device = { 'device_type': 'cisco_ios', 'host': ip, 'username': username, 'password': password, 'port': 22, 'verbose': True } device_list.append(cisco_device)
for device in device_list: connection = ConnectHandler(**device)