Python script to execute CLI commands via SSH on multiple devices


You manage large amount of devices and you want to execute commands and gather output from them in an automated way.


Use the following Python script. The script uses a CSV file with the following device information:

The script can be executed from shell against a CSV file:

This example script will display an output of ‘show interfaces’ command from all devices listed in the CSV file:


You will receive command output from all devices listed in the CSV file. Let me know in the comments if there are any issues!


Leave a Reply

Your email address will not be published.