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)
Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • 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
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜