Skip to main content

CryptoLabs SRE reverse-tunnel agent — connects your server to CryptoLabs AI SRE

Project description

CryptoLabs SRE Agent

A lightweight reverse-tunnel agent that connects your server to the CryptoLabs AI SRE investigation platform — no SSH keys, no port forwarding, no firewall changes.

Quick Start

# Install (requires Python 3.10+)
pipx install cryptolabs-sre-agent

# Connect using the token from your CryptoLabs SRE dashboard
# Option 1: token file (recommended — not visible in process list)
echo "YOUR_TOKEN" > /etc/sre-agent.token
chmod 600 /etc/sre-agent.token
sudo sre-agent connect --token-file /etc/sre-agent.token

# Option 2: environment variable
export SRE_AGENT_TOKEN="YOUR_TOKEN"
sudo sre-agent connect

# Option 3: CLI flag (token visible in `ps aux` — use for quick testing only)
sudo sre-agent connect --token YOUR_TOKEN

How it Works

  1. Installpipx install cryptolabs-sre-agent
  2. Runsudo sre-agent connect --token-file /etc/sre-agent.token
  3. The agent opens an outbound WebSocket (wss://) to sre.ai.cryptolabs.co.za
  4. The token links this agent to your registered server on the dashboard
  5. Commands are sent by the SRE system, executed locally, results returned

Security

Network

  • TLS enforced — agent refuses non-wss:// connections in production
  • Outbound only — no inbound ports opened on your machine
  • Heartbeat timeout — server drops idle connections after 90s of silence

Authentication

  • HMAC-SHA256 signed tokens — cryptographically bound to a single server
  • Token hashed in storage — only a SHA-256 hash is stored server-side (not the raw token)
  • Rate limiting — 10 failed auth attempts per IP triggers a 5-minute lockout
  • 10-second auth deadline — connections that don't authenticate are dropped

Execution Safety

  • Server-side allowlist — commands are validated by the SRE API's command allowlist before reaching the agent
  • Agent-side blocklist — defense-in-depth: the agent independently blocks catastrophic commands (rm -rf /, mkfs, dd to disk, fork bombs, halt/poweroff, writes to /etc/shadow, /root/.ssh/authorized_keys)
  • Output truncation — stdout/stderr capped at 1 MB per field
  • Concurrent limit — max 10 commands in parallel to prevent resource exhaustion
  • Command timeout — every command has a configurable timeout (default 300s)

Token Handling

  • --token-file recommended — avoids exposing token in process list
  • Environment variable (SRE_AGENT_TOKEN) — alternative to file
  • CLI flag (--token) — agent warns when this is used

Revocation

  • Deleting the server from the dashboard instantly disconnects the agent
  • Token revocation via API (DELETE /agent/token/{server_id})
  • Agent auto-shuts down when server sends disconnect message

Environment Variables

Variable Description
SRE_AGENT_TOKEN Alternative to --token flag
SRE_AGENT_TOKEN_FILE Alternative to --token-file flag
SRE_RELAY_URL Override the relay URL (default: wss://sre.ai.cryptolabs.co.za/agent/ws)

Running as a Service

# systemd (Linux) — using token file for security
sudo tee /etc/systemd/system/sre-agent.service << 'EOF'
[Unit]
Description=CryptoLabs SRE Agent
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/root/.local/bin/sre-agent connect --token-file /etc/sre-agent.token
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable --now sre-agent

Development

cd services/sre-agent
pip install -e ".[dev]"
pytest

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

cryptolabs_sre_agent-0.1.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

cryptolabs_sre_agent-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cryptolabs_sre_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a1d12079b360b6f4be624b834494d0be9890c0d4d6fda3b779c57d18d0c1433a
MD5 61dedb6d42fcf311fa62106d42b76e49
BLAKE2b-256 706b510be67c97ab89ae4d9b2d323a0c26ccc673a946ef1c03567d41c0957f55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptolabs_sre_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04e6057e9b8706a4b590ed55ec3f5016a48d5a4fb6557c448c5262316303fbfd
MD5 af680dcf0684c7d5156256eaadb13c03
BLAKE2b-256 aa4520d7304be59bdb69e99e8880c45e36498f522b9a2117fe155fceeda15adb

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