This is a python script collecting current running config from Cisco IOS devices and storing the configs in a Git repo.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Carsten Schmiemann 793a54918f
Fix spelling
12 months ago
readme_images Cropped image in readme 2 years ago
.gitignore Initial commit 2 years ago
LICENSE Update LICENSE 2 years ago Fix spelling 12 months ago Initial Commit 2 years ago
requirements.txt Updated requirements.txt 2 years ago

Track multiple Cisco IOS device config in a Git repository


This is a python script collecting current running config from a Cisco IOS devices and storing the configs in a Git repo.

This allows you to monitor for configuration changes and track changes to over time.

alt text


  1. Python - this has been tested with Python 3.8.6.
  2. Git installed on your computer.
  3. A remote Git repository. This has been tested against remote Github and our local Gitea installation repositories.
  4. A Bash (or compatible) terminal - the python script runs Git Bash commands directly in a terminal instance using subprocess.
  5. Access to an IOS device

Getting started

Clone this Git Repository

git clone

Open new Git repo folder in terminal

cd Cisco_IOS_Config_to_Git

Setup Python virtual environment

It is good practice to run Python scripts in a virtual environment.

Create virtual environment

python3 -m venv venv

Open the virtual environment

source venv/bin/activate

Install Python dependencies

pip install -r requirements.txt

Edit Python file

The Python script has some variables you need to define.

Edit host, username and password to match your device(s).

# Cisco MainSwitch connection details
device = {
    "device_type": "cisco_main_hub",
    "host": "",
    "username": "sysadmin",
    "password": "C1sco12345",

Edit git_repo_url to match your Git repository URL.

Optional - edit commit_message to specify what Git should use as the message for each commit.

# Git repository details
git_repo_url = ""
commit_message = "Automatic config update"

Run the Python script

To run the Python script


Check the result

The script automatically deletes all created files after the Git push is complete. This means there's nothing to see locally after it has ran.

Go to your remote Git repository and you should see your config uploaded.

If you make changes to the switch config and re-run the Python script, you will see Git track the changes between the new config and the old config. Check the changes by viewing the most recent Git commit!


  • If you have problems running the script, it is likely that the Git installed on your computer hasn't authenticated with the remote Git repository. The Python script relies on connection authentication credentials being cached on your computer.

To fix, manually clone the repository, and if prompted, enter authentication details.

git clone <git_repo_url>

You may need to use an access token rather than a password.

  • If you have problems by setting up your virtual env with getting a message that rust compiler is not installed, install it

Example for Debian based systems

apt install rustc
  • If you want to run it from systemd or cron, you need to include virtual env
/path/to/gitfolder/venv/bin/python3 /path/to/gitfolder/