Free tech learning for everyone, from basics to pro

Network AutomationNetworking SecurityIntermediate

Scrapli for network automation: fast SSH and NETCONF connections in Python

In short: Scrapli is a Python library for connecting to network devices over SSH and Telnet, with a sister library for NETCONF. It is fast, supports both normal and asyncio code, and offers built-in drivers for Cisco IOS XE, NX-OS and IOS XR, Juniper Junos and Arista EOS. Its response objects can be parsed with TextFSM or Genie.

Why Scrapli?

Netmiko is the best-known SSH library for network devices. Scrapli takes a different design with a focus on speed and modern Python, including native asyncio support for connecting to many devices at once.

Python SSH librariesNetmikoVery widely usedHuge platform supportMany examplesSynchronousScrapliFast, modern designSync and asyncioNETCONF via scrapli-netconfCore platforms built in
Figure 1. Both are good choices; Scrapli shines when speed or asyncio matters.

Installing and connecting

pip install scrapli
import os
from scrapli import Scrapli

device = {
    "host": "10.0.0.1",
    "auth_username": os.environ["NET_USER"],
    "auth_password": os.environ["NET_PASS"],
    "auth_strict_key": False,
    "platform": "cisco_iosxe",
}

with Scrapli(**device) as conn:
    response = conn.send_command("show version")
    print(response.result)

Setting auth_strict_key to False skips SSH host key checking, which is fine in a lab; in production, manage known host keys properly.

Structured output

    response = conn.send_command("show ip interface brief")
    parsed = response.textfsm_parse_output()
    for intf in parsed:
        print(intf)

Use genie_parse_output() instead if pyATS and Genie are installed.

Configuration

    result = conn.send_configs([
        "interface Loopback100",
        "description Managed by Scrapli",
    ])
    print(result.failed)

Asyncio

Scrapli's async drivers (for example AsyncScrapli with the asyncssh transport) let one Python process handle many connections concurrently. This is useful for collecting data from hundreds of devices quickly.

NETCONF

The scrapli-netconf package provides NETCONF operations (get, get-config, edit-config, commit) with the same style.

Scrapli or Netmiko?

Choose Netmiko for the widest platform list and the largest community. Choose Scrapli for speed, asyncio and clean response objects, especially on its core platforms. Nornir has plugins for both.

Real-world example: faster data collection

A team's nightly script collected inventory from 1,200 devices one at a time and took over two hours. Rewriting it with Scrapli's async driver and a limit of 50 concurrent connections cut the run to under ten minutes.

Practice

Which Scrapli parameter selects the device type?
The platform parameter, for example cisco_iosxe.
How can you parse Scrapli command output into structured data?
Call textfsm_parse_output() or genie_parse_output() on the response.
When might Scrapli be preferred over Netmiko?
When speed or asyncio support for many concurrent connections matters.

Key takeaways

  • Scrapli is a fast Python library for SSH and NETCONF to network devices.
  • Core drivers cover IOS XE, NX-OS, IOS XR, Junos and EOS.
  • Responses can be parsed with TextFSM or Genie.
  • Async support helps when working with many devices.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: