netmiko is a multi-vendor SSH Python library that simplifies the process of connecting to network devices via SSH. This library adds vendor-specific logic to paramiko, which is the de-facto SSH library in Python.
For example, to issue a command to a network device and obtain the returned data, you would typically need to:
- Set up an SSH connection.
- Understand the command prompt string for the given device and vendor.
- Issue the command, and then perform the necessary string handling to understand when the device has finished sending its response.
- Handle the various nuances that come with string handling such as paging and terminal widths.
Netmiko abstracts many of these complexities for you, by providing a Python library with a set of easy to use methods.
Let's look at some use cases that Netmiko can be applied to and then the features that Netmiko provides that makes them possible.
Below are some of the use cases that Netmiko can be used for:
- Configuration backups - Automate the retrieval of the output of the running configuration on a scheduled basis.
- Security audits - Run a command to understand if the device is running a vulnerable software version.
- Automate troubleshooting- Automate the process of running various commands to troubleshoot an issue.
- Structured parsing - Supports parsing via the TTP, TextFSM and Genie parsing libraries.
- Multi-vendor - Supports a large set of multi-vendor devices.
- Device configuration - Provides methods for applying configuration from a list of commands or a file of commands.
- Device config - Supports various methods for reading configuration from devices.
- Stability tuning - Supports various options for ensuring stability for slow devices or network transports.
"Using Python Context Managers for SSH connections - Packet Pushers." 1 Mar. 2015, https://packetpushers.net/using-python-context-managers/. Accessed 17 May. 2019. ↩︎