When it comes to network automation we are spoilt with the plethora of tools available to us. One tool that deserves its space within any network automation toolbox is Netmiko.

Netmiko is a multi-vendor Python SSH library that simplifies the process of configuring and obtaining data from your network devices.

In short, Netmiko provides support for a ton of devices, a low barrier of entry for learning, and various built-in features such as structured parsing. Therefore you can get some great automation wins - QUICK!

For example below shows you how to backup a device config with less than 10 lines of code:

# Install
$ pip3 install netmiko

# Create ConnectHandler
from netmiko import ConnectHandler

net_connect_ios = ConnectHandler(
    {
        "device_type": "cisco_ios",
        "host": "lab.packetflow.co.uk",
        "username": "username",
        "password": "password",
    }
)

# Collect config
output = net_connect_ios.send_command("show run")

# Write to file
with open("device-backup.txt", "w") as opened_file:
    opened_file.write(output)
Want to Learn Network Automation?
Join our membership and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜