Skip to content

Instantly share code, notes, and snippets.

@abrand67
Created February 26, 2026 16:23
Show Gist options
  • Select an option

  • Save abrand67/4d0344dac1a46c95536bba3a5f511674 to your computer and use it in GitHub Desktop.

Select an option

Save abrand67/4d0344dac1a46c95536bba3a5f511674 to your computer and use it in GitHub Desktop.
from getpass import getpass
from netmiko import ConnectHandler
# Prompt for device credentials
uname = input('Username: ')
pword = getpass()
command = "show version"
# collect devices that will be configured
hosts = [] # create list object
with open('hosts.txt', 'r') as hFile:
for line in hFile:
hosts.append(line.strip())
# cycle through each device sequentially and run the command
for h in hosts:
device = {
"device_type": "arista_eos",
"host": h,
"username": uname,
"password": pword,
"session_log": h + ".log",
}
# Connect and send command
with ConnectHandler(**device) as conn:
output = conn.send_command(command, use_textfsm=True)
for o in output:
print(h + ' has an uptime of ' + o['uptime'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment