Netmiko: a Python library for driving network devices over SSH
Multi-vendor library to simplify Paramiko SSH connections to network devices
At a glance
- What is it?
- Netmiko wraps Paramiko and hides per-vendor prompt and paging behaviour so that one Python script can talk to Cisco and a very broad set of other CLI platforms. It is a screen-scraping library, not a model-driven one, and that distinction decides where it fits.
- Who is it for?
- Netmiko fits engineers who already have Python and a list of CLI devices, and who need show output or a config push this week. It does not fit anyone who needs transactional, model-driven configuration across vendors: that is NAPALM or Ansible territory, and Netmiko will not give you rollback or diff semantics.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- ktbyers/netmiko4,330 ★ · +37
| Repository | 2026-09-24 | 2026-11-22 |
|---|---|---|
| ktbyers/netmiko | 4.3k | 4.3k |
37 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What Netmiko solves, and for whom
The README states the problem plainly: network automation against screen-scraping devices is mostly about gathering output from show commands and making configuration changes. Doing that directly over Paramiko means handling each vendor's prompt string, its paging behaviour, its enable mode, and its timing quirks yourself. Netmiko's stated aim is to do both operations across a broad set of platforms while abstracting away low-level state control, described as eliminating low-level regex pattern matching to the extent practical.
The audience is therefore narrow but deep. If you have a mixed fleet of switches and routers reachable over SSH, and you want a Python script that logs in, runs show ip int brief, and returns a string, Netmiko is aimed at you. If your devices expose a structured API such as NETCONF or RESTCONF, or you already have a source-of-truth system producing intended configuration, you are outside the problem Netmiko was built for. The library is a transport and prompt-handling layer, not a configuration management system.
One consequence worth stating early: Netmiko returns text. Any structure you want from that text comes from a parser you attach yourself, which is why the project ships TextFSM and ntc-templates as dependencies.
How the connection and command flow actually works
A Netmiko session starts from a plain dictionary of connection parameters. The device_type key selects a driver class: the README points to ssh_dispatcher.py and says the supported values are the CLASS_MAPPER keys. That lookup is the whole dispatch mechanism. ConnectHandler reads device_type, picks the matching class, and instantiates it with the remaining parameters.
The driver class carries the vendor-specific knowledge. It knows the prompt pattern to expect, how to disable paging, how to enter enable mode when a secret is supplied, and how long to wait for output to settle before declaring a command finished. send_command writes the command string to the channel and reads until the prompt matches; send_config_set does the same but wraps the commands in configuration mode entry and exit, which is why the README example output shows config term and end around the three logging commands.
Two optional parameters in the README's dictionary are worth noting because they change behaviour rather than just addressing. port defaults to 22, and secret defaults to an empty string. Supplying secret is what enables the privileged-mode path. The repository also exposes a redispatch function and an SSHDetect class in the API documentation, which means you can connect with a guessed driver and then switch, or probe a device to find its type before committing.
Because everything above is prompt matching, a device whose prompt does not match the driver's pattern is the main failure mode.
Installing Netmiko and running a first command
The README gives a single install line. The package requires Python 3.11 or newer according to pyproject.toml (the README says 3.11 through 3.15), and pulling it in also brings paramiko, scp, pyyaml, textfsm, ntc-templates, pyserial and rich.
pip install netmikoTwo optional extras exist. If you need Paramiko 4 compatibility, the README specifies a separate install target, and the same pattern applies to the bulk-encryption CLI and its ruamel.yaml dependency.
pip install "netmiko[par4]"
pip install "netmiko[bulk-encrypt]"With that done, the smallest useful script is the one from the README: build a device dictionary, hand it to ConnectHandler, and call send_command. The port and secret keys are optional and default to 22 and an empty string respectively.
from netmiko import ConnectHandler
cisco_881 = {
"device_type": "cisco_ios",
"host": "10.10.10.10",
"username": "test",
"password": "password",
"port": 8022,
"secret": "secret",
}
net_connect = ConnectHandler(**cisco_881)
output = net_connect.send_command("show ip int brief")
print(output)What you should see is the raw CLI table, header row and all, exactly as the device prints it. Configuration changes go through a different call, and the README shows that send_config_set takes a list and handles the mode transitions for you.
config_commands = ["logging buffered 20000", "logging buffered 20010", "no logging console"]
output = net_connect.send_config_set(config_commands)
print(output)The repository ships a matching set of runnable files under examples/, including send_command.py, config_change.py, conn_ssh_keys.py and session_log.py. Reading those is faster than reconstructing the calls from the API docs.
Where Netmiko is the wrong tool
The README's own framing is the honest limitation: this is screen-scraping. Output is a string, and every downstream decision depends on parsing that string correctly. Vendor output formats change between firmware versions, and when they do, a parser or a regex breaks silently while the connection itself still succeeds.
Prompt detection is the second constraint. The driver decides a command is finished when it sees what it expects. Devices that emit banners, unsolicited log messages, or a non-standard prompt can cause send_command to return early or to hang until the read timeout. The repository keeps a COMMON_ISSUES.md file precisely because these cases are common enough to document, and the README directs users there before opening an issue.
Third, there is no transaction. send_config_set enters configuration mode, sends lines in order, and exits. If command three of five fails, the first two are already applied. Netmiko does not compute a diff, does not validate against intended state, and does not roll back. If your change process requires atomicity, Netmiko is a component of that process at best, never the whole of it.
Finally, scale. The examples include conn_multiple_dev.py, so iterating over devices is anticipated, but each session is a separate SSH connection with its own timing.
Netmiko versus Paramiko, Ansible and NAPALM
The Paramiko comparison is the clearest one, because Netmiko sits directly on top of it. Paramiko is a general SSH implementation for Python. It gives you a channel and a transport, and nothing else. To use it against a router you would write the prompt matching, the paging disable, the enable-mode transition, and the read-until-quiet logic yourself, per vendor. Netmiko's dependencies list paramiko>=3.5.1, so installing Netmiko installs Paramiko regardless. The difference is not capability but who maintains the vendor knowledge.
Ansible's network modules take a different route: declarative task files, an inventory, and idempotency expectations. The unit of work is a playbook run across hosts, not a Python object. If your team already writes playbooks and wants reporting per host, Ansible is the higher-level fit. If you want a function that returns a string inside a larger Python program, Netmiko is the lower-level fit, and wrapping it in Ansible adds a layer you may not need.
NAPALM differs in kind rather than level. It targets model-driven interfaces and returns structured data, with configuration operations designed around replace and merge semantics. That gives you the diff and rollback behaviour Netmiko lacks, at the cost of requiring devices and drivers that support those interfaces. Netmiko works on devices that only ever offered a CLI, which is exactly the long tail NAPALM cannot reach.
Maintenance, licensing and upgrade cost
The repository is not archived, and the last push was on 2026-10-30. Release history shows v4.8.0 on 2026-09-21, v4.7.0 on 2026-05-12 and v4.6.0 on 2025-06-26. That cadence, roughly one minor release every few months, is consistent with a project that is still being worked on rather than one in maintenance-only mode.
The licence is MIT, declared both in the repository and in pyproject.toml as license = { text = "MIT" }. MIT is permissive: you can use, modify and redistribute the code, including in commercial products, provided the copyright notice and permission notice travel with it. That is a description of the licence text, not legal advice; if you are redistributing Netmiko inside a product, have your own counsel confirm the notice requirements and check license-dependencies.txt for the transitive obligations of paramiko, textfsm, ntc-templates and the rest.
Upgrade cost is where a screen-scraping library differs from a pure utility. Minor releases can add device types and adjust driver timing without touching your code, but they can also change how a given driver detects prompts, which surfaces as flaky behaviour on one platform rather than as a stack trace. The pyproject.toml also pins paramiko>=3.5.1 with a separate par4 extra for Paramiko 4, and a paramiko5 dependency group, so a Paramiko major upgrade is a deliberate opt-in rather than something pip will do to you silently. Pin your Netmiko version in CI and test the platforms you actually run before moving the pin.
Editorial conclusion
Netmiko fits engineers who already have Python and a list of CLI devices, and who need show output or a config push this week. It does not fit anyone who needs transactional, model-driven configuration across vendors: that is NAPALM or Ansible territory, and Netmiko will not give you rollback or diff semantics. Before adopting it, check that your exact platform appears in the CLASS_MAPPER keys in ssh_dispatcher.py, and read COMMON_ISSUES.md for the prompt-detection failure modes that affect your vendor.
Frequently asked questions
What is Netmiko used for?
It is a multi-vendor library for CLI connections to network devices, used to gather output from show commands and to make configuration changes. It abstracts the per-vendor prompt and paging handling so the same Python code works across a broad set of platforms.
What is the relationship between Netmiko and Paramiko?
Netmiko is built on top of Paramiko and lists paramiko>=3.5.1 as a dependency, so installing Netmiko installs Paramiko. Paramiko provides the SSH channel; Netmiko adds the vendor-specific prompt matching, paging and configuration-mode handling on top of it.
What is the difference between Netmiko and NAPALM?
Netmiko drives the CLI and returns text, which you then parse yourself. NAPALM targets model-driven interfaces and returns structured data with configuration operations built around replace and merge semantics. Netmiko reaches devices that only expose a CLI, which is the case NAPALM cannot cover.
How do I install Netmiko?
The README gives a single pip command: pip install netmiko. It requires Python 3.11 or newer (the README says 3.11 through 3.15), and separate extras exist for Paramiko 4 compatibility and for the bulk-encryption CLI.
How do I use Netmiko in Python?
Build a dictionary with device_type, host, username and password, pass it to ConnectHandler, then call send_command for show output or send_config_set with a list of commands for configuration changes. The repository's examples/ directory contains runnable versions of each pattern.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/ktbyers-netmiko)Star history chart for your README
[](https://hysenlabs.com/projects/ktbyers-netmiko)Was this useful?