"Want more expert insights and updates? Follow us on LinkedIn and explore our company page to connect with us directly. Don’t miss out - click the link and join the conversation!"
Follow us on LinkedIn / plexinor
Company Website Https://www.plexinor.com
Beginner's Guide: Basic Python Script to execute commands on "MULTIPLE" router using ssh
The full script is given below
lab@admin:~$ cat SSH-Show-Commands
from netmiko import Netmiko
from getpass import getpass
my_device = {
"host": "192.168.0.85",
"username": "lab",
"password": getpass(),
"device_type": "juniper_junos",
}
my_device1 = {
"host": "192.168.0.122",
"username": "lab",
"password": getpass(),
"device_type": "juniper_junos",
}
my_device2 = {
"host": "192.168.0.75",
"username": "lab",
"password": getpass(),
"device_type": "juniper_junos",
}
ALL = [my_device,my_device1,my_device2]
for dd in ALL:
net_connect = Netmiko(**dd)
output = net_connect.send_command("show version|no-more")
print(output)
output = net_connect.send_command("show arp no-resolve")
print(output)
net_connect.disconnect()