← Back to all posts
ArchitectureSecuritySSHAgentDocker

Why a Lightweight Go Agent Beats SSH for VPS & Docker Management

tug.sh Team

tug.sh Team

Core Team

3 min read

When building a centralized dashboard to manage virtual private servers (VPS), developers face a fundamental architectural choice: Should the control plane connect to user servers via SSH, or should the servers run a lightweight local agent that communicates back to the dashboard?

While the SSH model is popular because it requires "zero installation" on the server, it introduces massive security vulnerabilities and fragile, unreliable code.

Here is why tug.sh uses a dedicated, compiled Go agent (tug-agent) instead of SSH connections.


1. The SSH Security Nightmare (Centralized Vulnerability)

If a management platform uses SSH to control your servers, it means the platform's central database must store either:

  • Your server's root SSH private keys, or
  • A custom SSH key that has passwordless sudo access.

This turns the central SaaS platform into the ultimate target for hackers (Target Number One).

What happens if the platform gets breached?

  • In the SSH model: If the central control plane is compromised, the attacker instantly gains root access to thousands of customer production servers at once. They can steal database contents, install ransomware, or delete entire clusters across the globe.
  • In the Agent-based model: With tug-agent, your servers initiate a secure, outgoing WebSocket connection back to the API. Your SSH keys never leave your local computer. If the central tug.sh API is compromised, the dashboard might go offline, but the attacker does not gain shell access to your VPS. Your servers continue running safely, and no root keys can be leaked because the platform never had them.

2. "Parsing Hell" vs. Structured JSON API

Under the hood, managing Docker containers requires querying status, listing networks, reading logs, and triggering restarts.

The Fragile SSH Parser

In an SSH-based platform, the central server sends raw bash commands over the network (e.g., docker ps -a --format ...) and has to parse the stdout returned as raw text.

This creates what developers call Parsing Hell:

  • The platform has to use complex regular expressions (regex) to parse terminal outputs.
  • If a user changes their default shell, updates their bash version, or customizes their terminal prompts, the output format changes slightly, causing the regex parser to fail.
  • Parsing long logs or real-time event streams over an interactive SSH session is notoriously prone to connection drops and memory leaks.

The Robust Go Agent

A compiled agent (written in Go) runs directly on the VPS. It communicates with the local Docker daemon using the official Docker SDK via Unix sockets.

  • There is no text parsing. The agent gets structured, type-safe data directly from the Docker engine.
  • The agent serializes this data into clean, structured JSON and streams it to the API over WebSockets.
  • If a connection drops, the agent automatically retries with an exponential backoff.
  • The central API receives predictable, typed payloads that are extremely fast to process and highly reliable.

Conclusion

The "agentless" appeal of SSH is tempting at first glance because you don't have to install anything. However, the trade-off is giving a third-party service root access keys to your production servers and relying on fragile shell parsers.

By running a tiny, secure Go agent that consumes less than 15MB of RAM, you get the best of both worlds: robust, type-safe Docker orchestration and absolute peace of mind knowing your SSH keys are safe.

To experience the reliability of agent-based VPS control, connect your first server to tug.sh in under 5 seconds!