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

Uploaded Python 3

File details

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

File metadata

  • Download URL: cryptolabs_sre_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 14.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 2b2646d47c6c8d5939191f48d2bf8f2f6857ee3088c3a74b6e59c47050a92482
MD5 cdee15c993451b92774ddee8aed76010
BLAKE2b-256 695b2c3185b5cdf1b402ddf8a0ae8c3ceb80e8c7eee8f53f176621926bacbadd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptolabs_sre_agent-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 337b42bf366fffcb88f63af261054e41fac70e72cf3e6c6f52c8eea08e074a65
MD5 90a7633a61e6b20bde10f891fa69b85d
BLAKE2b-256 e800928b44f5549dbbba22cabcdc852e2da7bb6a36a8a9fa3a818f8735016d86

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