Skip to main content

Lightweight agent that backs up network device configs (MikroTik, Ubiquiti) to ConfigStash

Project description

ConfigStash Agent

A small on-premise collector that backs up your network device configs (MikroTik RouterOS, Ubiquiti EdgeRouter/EdgeSwitch/UniFi Switch) to your ConfigStash server.

Your device credentials never leave your network. The agent connects to devices over SSH locally and pushes only the resulting config text to the API over outbound HTTPS, authenticated with an agent token. No inbound ports needed.

Quick Start: from zero to first backup in 5 minutes

Prerequisites: Python 3.12+, a ConfigStash account, SSH access to at least one device.

1. Install (30 sec)

pip install git+https://github.com/configstash/configstash-agent.git

2. Get an agent token (1 min)

In the ConfigStash web UI: Settings → Agents → Create agent. Copy the token (cst_agent_...) — it is shown only once.

3. Initialize (30 sec)

configstash-agent init

Enter your API URL (e.g. https://api.yourdomain.com) and the agent token. This creates ~/.configstash/config.yaml (permissions 600).

4. Add a device (1 min)

In the web UI: Dashboard → Add device. Copy the device ID it shows, then add the device to ~/.configstash/config.yaml:

devices:
  - name: "Office MikroTik"
    device_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"   # from the web UI
    host: 192.168.88.1
    device_type: mikrotik_routeros    # mikrotik_routeros | ubiquiti_edgerouter | ubiquiti_edgeswitch | ubiquiti_unifiswitch
    username: admin
    password: "your-ssh-password"
    port: 22

Tip: create a dedicated read-only SSH user on the device for backups.

5. Test and run (2 min)

configstash-agent test    # dry run: SSH connect + collect, nothing sent
configstash-agent run     # collect and upload your first backup

Open the web UI — your backup is there. Done. 🎉

6. Keep it running

configstash-agent install-service   # auto-start on boot (systemd / launchd)

By default backups run every 6 hours (schedule: "0 */6 * * *" — standard cron syntax, edit in config.yaml) with a heartbeat every 5 minutes.

No devices yet? Try demo mode

configstash-agent demo --api-url https://api.yourdomain.com --token cst_agent_... --repeat 3

Creates a virtual MikroTik and uploads realistic configs with changes between runs — great for seeing the diff viewer in action.

All commands

Command What it does
init Interactive config creation
test Dry run: SSH to all devices, don't upload
run One-shot: collect and upload all devices
start Foreground daemon on cron schedule (-d to background)
stop / status Manage the running daemon
install-service / uninstall-service systemd/launchd auto-start
demo Fake device backups, no SSH needed
uninstall Remove agent and local data (cloud backups stay)

Docker

cp config.example.yaml config.yaml   # edit it
docker compose up -d

On Linux, uncomment network_mode: host in docker-compose.yml if your devices aren't reachable from the container network.

Notes

  • Failed uploads are queued in ~/.configstash/pending/ and retried on the next run — safe across API downtime.
  • All local state lives in ~/.configstash/ (mode 700).
  • Always use an https:// API URL in production — the agent warns otherwise.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

configstash_agent-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configstash_agent-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file configstash_agent-0.1.0.tar.gz.

File metadata

  • Download URL: configstash_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for configstash_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63efada4e5a0c7e572768a8c95794202c1dcb8ef2a693e9528707f3474f064e3
MD5 cace6bd25429866e17610e3fa6d0ccfe
BLAKE2b-256 c50c6c6551b519d94c86514a36d45a24668bdc1de7c0c0f671a7925438c99643

See more details on using hashes here.

File details

Details for the file configstash_agent-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for configstash_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cee4d54f028b9cc338f3a943984cbe662053c8310f767cc8b9f3cd5db125188d
MD5 6a4ad015fc79885847d473eca47d1b8a
BLAKE2b-256 9bbfef704d2dd94cbe11e1859cfe8bb445e6126ef34c9c7f6a3042558af542cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page