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 $(which sre-agent) connect --token-file /etc/sre-agent.token
# Option 2: environment variable
export SRE_AGENT_TOKEN="YOUR_TOKEN"
sudo $(which sre-agent) connect
# Option 3: CLI flag (token visible in `ps aux` — use for quick testing only)
sudo $(which sre-agent) connect --token YOUR_TOKEN
How it Works
- Install —
pipx install cryptolabs-sre-agent - Run —
sudo $(which sre-agent) connect --token-file /etc/sre-agent.token - The agent opens an outbound WebSocket (
wss://) tosre.ai.cryptolabs.co.za - The token links this agent to your registered server on the dashboard
- 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,ddto 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-filerecommended — 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
Remote terminal (local consent)
The agent can open interactive root shells and run commands for the machine owner
through CryptoLabs (srecli). It is off by default and only you can turn it on, on
the machine itself.
sudo sre-agent terminal on # allow (prints exactly what this allows)
sudo sre-agent terminal off # refuse
sre-agent terminal status # prints on/off and, when off, why
- Consent is the file
/etc/sre-agent.conf([terminal]/enabled = true). It counts only if it is a regular file owned by root and not writable by group or others; anything else (missing, wrong owner, unreadable,enablednottrue) means off. The agent re-reads it for every request and every 5 seconds during a session; turning it off ends open sessions. - Each session uses its own outbound
wss://connection; the agent never takes a host or URL from the server. Sessions end when the connection drops, on timeout (PTY: 30 min idle, 8 h maximum), or when you turn consent off. At most 3 run at once. - Read-only commands run inside a
systemd-runsandbox (no writes outside a private/tmp, no signals to other processes, no docker, no kernel/mount/clock calls). Read-only is not confidential: output can contain secrets. - This switch protects against mistakes and policy, not against a compromised CryptoLabs
server, which can already run root commands through the agent. The hard stop is
sudo systemctl stop sre-agent.
Protocol: docs/contracts/2026-10-01-terminal-agent-protocol.html.
srecli: the owner's command-line client
srecli runs on your own computer (not on the servers) and reaches the machines
you registered with CryptoLabs AI SRE. It never needs root and is installed from the
same package as the agent:
pipx install 'cryptolabs-sre-agent[cli]' # [cli] adds keyring, for the macOS Keychain
srecli login # approve the code in your browser
srecli servers # hostname, online, terminal setting, agent version, ready
srecli show venter-h100x4-01 # details of one server (a hostname or a server id)
srecli exec venter-h100x4-01 -- nvidia-smi -L
srecli elevate venter-h100x4-01 # ask for write access; approve it in the browser
srecli exec venter-h100x4-01 -w --timeout 120 -- systemctl restart nginx
srecli connect venter-h100x4-01 # live root shell (needs the same approval); Ctrl-] leaves
srecli logout # revokes the key in use (SRECLI_KEY first, else the stored key)
exec SERVER [-w] [--timeout N] -- COMMAND...: the words after--are joined with single spaces and run as one shell command. Output goes to your stdout and stderr, piped stdin is streamed, and the exit status is the remote one (124timeout,126refused,143when a grant ended,255connection lost,2usage error or an ambiguous hostname). Leaving on purpose decides the status: Ctrl-] inconnectis0, Ctrl-C is130, SIGTERM is143, whatever the server sends afterwards.1is a local error, including a rejected key (Your key is not valid. Run: srecli login),Rate limited, try again later, and a server whose remote terminal is not enabled.- Without
-wa command must be on the read-only command list. Write commands andconnectneed an approved grant for the key you are using, whichsrecli elevaterequests. The grant belongs to that key only and is shown to you in the browser with a second-factor check. --jsononserversandshowprints the API answer as JSON.- Browser:
srecliopens onlyhttps://www.cryptolabs.co.za/links (and loopback links whenSRECLI_URLis a loopback test server). Any other link, or a machine with no graphical browser, only gets the link printed. - Text from the server (hostnames, OS info, labels, messages) has escape sequences, control
characters and every invisible or unassigned Unicode character (categories Cf, Co, Cs, Cn: direction
marks, zero-width and tag characters) removed, and line breaks turned into spaces, before it is
printed. A missing value prints as
-.--jsonkeeps the raw values, escaped by JSON. - An error answer that is not JSON (for example from nginx) is reported as the HTTP status and a short generic text. A refused session upgrade maps like the REST answer: 401 is the key hint, 429 is rate limited, 503 is "not enabled".
srecli elevatewaits for your approval and stops with exit1("the request expired") 30 s after the request'srequest_expires_at(at most an hour from the request in any case). It retries a 429 or 503 until then; a grant status it does not know is an error.sreclinever sends a key that is notsre_pk_plus 43 letters and digits, and ignores proxy environment variables (HTTPS_PROXYand the like) for both REST and the session.srecli loginchecks that the key can be stored before it asks for a code. If storing fails after a key was issued, it revokes that key at once and exits1. With a keyring it tries a throwaway entry first and falls back to the file if the keyring refuses. If the key is stored but the older copy in the other store cannot be removed, that is a warning, not a failed login.- The key is stored in the macOS Keychain (service
srecli) whenkeyringis installed, else in~/.config/srecli/credentials(mode 0600, with a warning). It is never put on a command line or printed.SRECLI_KEYin the environment takes precedence over a stored key.srecliwarns when the key expires within 7 days; runsrecli loginagain to renew. srecli logoutrevokes the key in use:SRECLI_KEYfirst, then the stored key. It deletes the stored copy only if it is that key, so logging out an assistant'sSRECLI_KEYnever touches the key you stored for yourself. If the revoke fails, nothing is deleted and you can retry.
Using srecli with an AI coding assistant
- Give the assistant its own key: run
srecli loginon a separate account or computer, or setSRECLI_KEYfor the assistant's process. A read key can list servers and run read-only commands and nothing else. - Writes need your approval: the assistant can run
srecli elevate, but the grant only starts after you approve it in your browser, it lasts at most 60 minutes (default 30), and it applies to the assistant's key only, never to your own key. - Read output can contain secrets (environment variables, config files, logs). Anything
srecli execprints is visible to the assistant. Runsrecli logoutwith the assistant'sSRECLI_KEYset when you are done: that revokes the assistant's key and leaves yours.
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
Support
Need help? Join our Discord: https://discord.gg/7yeHdf5BuC
Development
cd services/sre-agent
pip install -e ".[dev]"
pytest
Metadata
Release files for cryptolabs-sre-agent 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cryptolabs_sre_agent-0.3.0.tar.gz | 136.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cryptolabs_sre_agent-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 202.2 kB
Release files / cryptolabs_sre_agent-0.3.0.tar.gz
| Download URL | cryptolabs_sre_agent-0.3.0.tar.gz |
|---|---|
| Size | 136.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8c4a343d892b526105e20f4c7bf213b2a173930a7d761d5b2f7b23c57e048ff
|
|
BLAKE2b-256 checksum How to use checksums |
201d96f893e6f54ecab78441ba35bb8ef1cb0f232d6e505168bdb816a92b729a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / cryptolabs_sre_agent-0.3.0-py3-none-any.whl
| Download URL | cryptolabs_sre_agent-0.3.0-py3-none-any.whl |
|---|---|
| Size | 65.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
232228f7251e811f0acebe7b2d8896451c3b7d6c2c3ec7b4d3e4b156e5588c15
|
|
BLAKE2b-256 checksum How to use checksums |
bd5c0d09d5778965ef32da9851f371956a4f25350f07d7bffd5889686749fa25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for cryptolabs-sre-agent 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.