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 configstash-agent

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.

What gets uploaded (and what never does)

Device credentials never leave this machine — they live only in ~/.configstash/config.yaml and are used for outbound SSH to your devices. The only thing sent to the API is config text, and by default it is sanitized first:

  • Secrets are masked. Passwords, pre-shared keys, SNMP communities and similar values are replaced with **REDACTED** before upload. RouterOS /export already omits sensitive fields; EdgeOS / EdgeSwitch output prints them in clear text, so this matters.
  • Public IPs are pseudonymized. Globally routable addresses become stable EXT-IP-xxxxxx tokens derived from a salt stored only on this machine (~/.configstash/ip_salt). The same address always maps to the same token, so diffs stay meaningful — but your public addresses are never stored in the cloud. Private ranges (10.x, 192.168.x, …) are kept as-is.

Both passes can be disabled in config.yaml (sanitize_secrets, sanitize_public_ips) if you prefer verbatim backups — see config.example.yaml for the trade-off.

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.2.0.tar.gz (21.9 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.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: configstash_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 21.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 4bd546bb9c5897ba1c7dd3b691dfed47055efb5c4954975c3281e918a950d5ee
MD5 9500493a0e56517a85e918846f0c64c7
BLAKE2b-256 6f7f8b446a81d058254959a547624f52004c887576e2ab18cb61e8bda6263fb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for configstash_agent-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79c01bf1259101b32dbf819a4d394d56b9b0b3cc83fad067a3802b1d72ede81b
MD5 2d3975ce595f13a448a751ccdaf88521
BLAKE2b-256 db482cc0961eafbbbcd08098c6321b0fb167f1bfaf5793bcfaabe609c2e40c60

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