Implementing and Operating Cisco Enterprise Network Core Technologies (ENCOR) v1.2AutomationEasy

A network engineer is developing a Python script to interact with a Cisco device. The script needs to send a series of configuration commands to the device and receive the output. The engineer wants to use a standard library that offers a simple way to establish an SSH connection, send commands, and retrieve responses without needing to parse complex XML or JSON structures directly for basic command-line interactions. Which Python library is most suitable for this task?

  1. Arequests
  2. Bnetmiko
  3. Cparamiko
  4. Dxml.etree.ElementTree
Show answer & explanation

Correct answer: C. paramiko

Paramiko is a Python library that implements the SSHv2 protocol, providing both client and server functionality. It allows Python scripts to connect to SSH servers, execute commands, and transfer files, making it ideal for basic command-line interactions with network devices.

Why the other options are wrong

  • A. Requests is an HTTP library, not suitable for SSH communication.
  • B. Netmiko is a multi-vendor SSH library built on top of Paramiko, offering more advanced features but Paramiko itself is sufficient for basic SSH interactions.
  • D. xml.etree.ElementTree is for parsing XML data, not for establishing SSH connections or sending commands.

Paramiko Library

A Python library that provides a pure Python (2.7/3.4+) implementation of the SSHv2 protocol, enabling client and server functionality for SSH connections.

  • Implements SSHv2 protocol.
  • Allows executing commands and transferring files over SSH.
  • Suitable for basic command-line automation with network devices.

Memory trick: Python's many tools, but for direct SSH, Paramiko's the key.

More Automation questions