Python: Collect version and config with “not sure” credentials

Sometimes there is some mix in the configuration of the devices: some configured with TACACS, some are still with local username, but not sure with which one. I’ve created a script, that logs into the device (SSH first, if failed – Telnet), collects version and startup-config, saves it to the file and tracks the result file.

I used threads in this one, but asyncio is in my list:)

The result looks like:

The process of how it works:

GitHub repo is here

A little breakdown: includes all possible usernames/passwords that will be used to get into the device. It’s better to put the most used first: – ping the IP address first, if available – tries SSH, if failed – tries Telnet. It also collects which username was used for each IP address – main script. Created class Device with different methods to init and close connection, collect_config and static method to write the result file:

Usually, I don’t use the progress bar but added this one just for fun (from here).


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *