Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

SSH / CLI

Direct answer

SSH/CLI automation sends normal CLI commands over SSH with libraries like Netmiko, Paramiko or Scrapli and parses the text output, working on almost any device but sensitive to prompts and output formats.

When to use this

Use this when automating Cisco devices via SSH and CLI.

First 30 seconds

1. SSH/CLI automation on Cisco.

2. network_cli connection with become for enable.

3. Parse with Genie/TextFSM.

4. ios_config with backup and diff.

5. Handle prompts.

Operational verification

SSH → exec/enable → commands

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Cisco network automation
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.

PlatformCisco network automation · 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 Cisco devices via SSH and CLI.
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.

3 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 Verification path Verify boundary

Record device ID/management endpoint, platform/version, YANG model/revision or CLI operation, request/run ID; inspect the runtime/control-plane result; then query the selected Cisco device configuration/operational state and forwarding behavior where relevant through an independent read path and compare it with the versioned intent. For Cisco Automation → SSH / CLI, the evidence must connect the control-plane result to the selected Cisco device configuration/operational state and forwarding behavior where relevant and explain any gap between desired, controller-reported and consumer-visible state.

Step 2 Common mistakes Narrow the fault
  • Screen-scraping without structured parsing.
  • Forgetting terminal length 0.
Step 3 Where it fails Narrow the fault

Failure analysis for Cisco Automation → SSH / CLI should follow the path through the components: inventory/controller → transport/API/CLI → device parser/YANG datastore → control-plane state → forwarding/operational read-back. Common failure classes include platform syntax/model drift, privilege/auth mismatch, partial config, parser success without feature activation, asynchronous convergence and controller cache differing from device state. Before retrying a mutating operation, read current target state using the stable identity device ID/management endpoint, platform/version, YANG model/revision or CLI operation, request/run ID; if state is unknown, stop broad retries.

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
  • Works on almost any device.
  • Parsing text is fragile.
  • Handle prompts and timeouts.
Key checks
  • ansible <dev> -m cisco.ios.ios_command -a "commands='show run | i hostname'" — CLI via Ansible
  • python3 -c 'import netmiko' — Netmiko
  • privilege level 15 or enable via become — access
ReferenceWhy it matters1 section · depth on demand

In depth

SSH/CLI automation on Cisco devices sends the same commands an engineer would type, through libraries that handle login, prompts and paging. It works on every IOS, IOS XE, NX-OS and IOS XR device, which makes it the universal fallback when no API is available.

LibraryStrength
NetmikoSimple, many platforms
ScrapliFast, async support
Ansible network_cliPlaybook-based, resource modules
Unicon (pyATS)Rich device state handling
from scrapli.driver.core import IOSXEDriver
with IOSXEDriver(host="sw01", auth_username=u, auth_password=p, auth_strict_key=True) as c:
    print(c.send_command("show version").genie_parse_output()["version"]["version"])

Parse output into structured data immediately; scraping text with ad-hoc regexes breaks when output formats change.

ReferenceImportant terms & boundaries1 section · depth on demand

Mechanics

Cisco Automation → SSH / CLI is owned at runtime by the automation client/controller communicating with Cisco devices through supported APIs, YANG models or CLI. Its durable intent is versioned automation with device inventory, platform/model capability expectations and bounded configuration intent; the stable identity contract is device ID/management endpoint, platform/version, YANG model/revision or CLI operation, request/run ID. The consumer-visible target is the selected Cisco device configuration/operational state and forwarding behavior where relevant. The operating invariants are that device/platform capability is known, configuration scope is explicit, parser/model assumptions match software version, write success is followed by read-back and control/data-plane verification remains separate. Follow the chain of components inventory/controller → transport/API/CLI → device parser/YANG datastore → control-plane state → forwarding/operational read-back and record which layer currently owns truth. The linked authority for bounded mechanics is Cisco DevNet — YANG Suite Documentation; documentation support is separate from observed lab/production Evidence.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
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 docCisco network automation current

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

Basis: https://developer.cisco.com/docs/yangsuite/ · confidence 94%
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Capture at minimum device, platform/version, request/command/RPC ID, model/path, config diff, error, operational state and forwarding/consumer verification.

Confirmation

Confirm action

Continue?