Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

SSH Automation · Python Automation

Direct answer

SSH automation in Python uses Paramiko for raw SSH, Netmiko or Scrapli for network devices and Fabric for servers, sending commands and handling prompts, keys and timeouts.

When to use this

Use this when automating SSH from Python.

First 30 seconds

1. SSH automation with paramiko, netmiko, fabric, asyncssh.

2. Verify host keys.

3. Key-based auth from vault.

4. Timeouts and error handling.

5. Prefer APIs when available.

Operational verification

script → SSH (verified host key) → commands → parsed output

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Python automation runtime
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPython automation runtime · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when automating SSH from Python.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Common mistakes Narrow the fault
  • Screen-scraping without parsing (TextFSM/Genie).
  • Not saving the configuration after changes.
  • Disabling host-key checking permanently.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Paramiko for raw SSH, Netmiko/Scrapli for network devices, Fabric for servers.
  • Handle prompts and timeouts.
  • Use SSH keys.
Key checks
  • python3 -c 'import paramiko' — library present
  • Host key verification (no AutoAddPolicy in prod) — security
  • Netmiko/Fabric for devices/hosts — libraries
ReferenceWhy it matters1 section · depth on demand

What it is

SSH automation logs in to devices and runs commands or pushes config: Netmiko and Scrapli for network CLIs, Paramiko for raw SSH. Prefer APIs where the device has one.

ReferenceImportant terms & boundaries2 sections · depth on demand

How it works

Netmiko and Scrapli open an SSH session, detect the prompt, disable paging and send commands, returning the raw text; with TextFSM/TTP/Genie templates the output becomes structured data. Configuration changes go through config mode and should be followed by a read-back and write memory (or copy run start).

Example

from netmiko import ConnectHandler
with ConnectHandler(device_type="cisco_ios", host=h, username=u, password=p) as c:
    out = c.send_command("show ip interface brief", use_textfsm=True)
    c.send_config_set(["interface Gi0/1", "description uplink"])
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPython automation runtime current

Authoritative/upstream documentation reviewed for bounded claims in Python Automation > SSH Automation. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.python.org/3/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Confirmation

Confirm action

Continue?