What Was I Trying to Do?
Managing personal servers and home lab appliances when away from a laptop usually means struggling with slow mobile SSH apps on touchscreen keyboards. Opening SSH ports to the public internet also invites continuous automated brute-force attacks from IP scanning bots.
I engineered the S.A.R.A. Task Control Plane as an event-driven system daemon that listens for cryptographically signed administrative commands over Telegram, executes whitelisted operations in a sandbox, and returns clean markdown status digests.
Security Architecture
Telegram User ➔ TLS Webhook with HMAC-SHA256 Signature ➔ Whitelist Command Parser ➔ Restricted Linux Subprocess ➔ Sanitized Output Stream ➔ Response Message
- Zero Public SSH Ports:
- Server runs without external inbound port forwards. The daemon polls Telegram long-polling or accepts webhooks behind Cloudflare Tunnel.
- HMAC-SHA256 Payload Verification:
- Every inbound control message is validated against the sender user ID and a rotating secret key before reaching the command dispatcher.
- Strict Command Whitelist:
- Arbitrary shell execution is completely disallowed. Commands are mapped to strict deterministic functions:
/status: Queries systemd service health and CPU load./disk: Runsdf -hand reports disk usage percentages./cleanup: Purges dangling Docker containers and systemd journal logs older than 7 days./restart <service>: Restarts only approved application daemons.
- Arbitrary shell execution is completely disallowed. Commands are mapped to strict deterministic functions:
Key Highlights & Performance
- Execution Latency: Command-to-response roundtrip time averages under 850 milliseconds.
- Memory Footprint: The Node.js daemon runs as an isolated systemd unit consuming under 28 MB of RAM.
- Self-Healing: Managed by systemd with
Restart=alwaysandWatchdogSec=30s, auto-recovering within 2 seconds if a process fault occurs.
What I Learned
Allowing arbitrary shell input via chat interfaces is a major security vulnerability waiting to happen. Constraining remote mobile operations to a strict whitelist of parameterized tasks provides complete operational peace of mind.