Python // Lesson 5: Netmiko

  1. Netmiko Introduction and Basics 
    Video link
    Length is 8 minutes
  2. Netmiko Show Commands
    Video link
    Length is 13 minutes
  3. Netmiko and Prompting
    Video link
    Length is 12 minutes
  4. Netmiko and TextFSM
    Video link
    Length is 10 minutes
  5. Netmiko Config Changes
    Video link
    Length is 8 minutes
  6. Netmiko Troubleshooting
    Video link
    Length is 9 minutes

Additional Content:

Netmiko Readme

Netmiko Examples

Netmiko Tutorial
This tutorial is a bit old, but still should be generally correct.


Reference code for these exercises is posted on GitHub at:

Note, you will need some sort of a network device to work on these exercises. This can be a virtual or physical device. Make sure you are only working on test or lab devices.

1. Using Netmiko, establish a connection to a network device and print out the device’s prompt.

2. Use send_command() to send a show command down the SSH channel. Retrieve the results and print the results to the screen.

3. Find a command on your device that has additional prompting. Use send_command_timing to send the command down the SSH channel. Capture the output and handle the additional prompting.

4. Use send_config_set() and send_config_from_file() to make configuration changes. 

The configuration changes should be benign. For example, on Cisco IOS I typically change the logging buffer size. 

As part of your program verify that the configuration change occurred properly. For example, use send_command() to execute ‘show run’ and verify the new configuration.

5. Optional, use send_command() in conjunction with ntc-templates to execute a show command. Have TextFSM automatically convert this show command output to structured data.

6. Optional, connect to three networking devices one after the other. Use send_command() to execute a show command on each of these devices. Print this output to the screen.

As part of this process, I provided links to several documents that might be helpful from a Netmiko perspective:

API Documentation
Netmiko and What Constitutes Done
Netmiko and TextFSM
Netmiko and Secure Copy
Netmiko SSH Proxy Support

I also provided links to some useful Netmiko examples:

Simple Connection
Simple Connection using a Dictionary
Simple Connection to Multiple Devices
Basic Show Command
Handling Additional Prompting
Basic Config Change
Config Change from File
SSH Proxy
Basic Threads Example
Platform Autodection using SSH

In additional to centralizing these links, I also updated the tutorial reference code to Python36 and cleaned up the page’s styling (i.e. added Python syntax highlighting to the code shown on the page).