The Problem

Organizations with dozens of Linux hosts need a single entry point for SSH, file transfer, and port‑forwarding. Managing sshd on each machine, rotating keys, and keeping firewall rules in sync is error‑prone. A centralized gateway reduces operational overhead and improves auditability.

What This Does

ShellHub supplies a web‑based SSH gateway and an accompanying agent that runs on each target device. The gateway (gateway/main.go) accepts client SSH connections, authenticates users, and forwards commands to the agent (agent/main.go). The agent implements the agent/pkg/agentd package, which handles key validation, command execution (agent/server/modes/host/command/command_native.go), SFTP support (agent/sftp.go), and session recording. The UI (ui/) provides a browser interface that talks to the gateway API (gateway/modules.go).

How It Is Wired

Entry point: gateway/main.go loads the configuration (gateway/config.go), registers modules (gateway/modules.go), and starts the SSH server. SSH flow: On connection, gateway/caddy.go creates a Caddyfile.tmpl‑based listener, then gateway/server.go uses github.com/gliderlabs/ssh to accept sessions. Authentication: The agent/server/modes/host/authenticator.go verifies public‑key fingerprints against the agent’s key store (agent/pkg/keygen/keygen.go). Command execution: The agent receives the request via its HTTP API (agent/server/server.go → agent/server/modes/connector/connector.go) and dispatches to agent/server/modes/host/command/command_native.go. Effects:

  • Database: agent stores key mappings in a local SQLite file (agent/pkg/agentd/tenant.go).
  • Filesystem: command handlers read/write target files (agent/server/modes/host/command/command_docker.go).
  • Network: the gateway sets up port forwarding (gateway/caddy.go → gateway/modules.go).

The call graph is a deep tree rooted at gateway/main.go; only a handful of functions (gateway/server.go, agent/server/server.go) have wide blast radius across the stack.

How To Use It

Setup

git clone https://github.com/moses-y/shellhub
cd shellhub
make build  # builds both gateway and agent binaries

Or use Docker:

docker compose -f docker-compose.yml up -d

Configuration

  • .env – contains SHELLHUB_SECRET, DB_URL, etc.
  • gateway/config.go reads SHELLHUB_GW_PORT and TLS settings.
  • agent/connector.go expects SHELLHUB_GW_URL to reach the gateway.

Running

# Stand‑alone
go run gateway/main.go
# Agent
go run agent/main.go

Or via the provided bin/docker-compose script to launch both.

Real‑World Use

An infrastructure team can deploy the agent on every server (agent/Dockerfile), then add the device via the UI. Users SSH to gateway.example.com using their private key; the gateway forwards the session to the chosen agent, which executes commands locally and streams output back. SFTP transfers and port forwarding are handled automatically.

Code Health & Issues

  • Security: The repository contains a .env file that may hold secrets. Review or remove it before committing.
  • Testing: 1057 test files cover most agent logic, but the UI tests are limited to end‑to‑end (.github/workflows/ui-e2e.yml).
  • Documentation: 186 doc files exist, yet the README lacks a step‑by‑step deployment guide.

No static analysis report is present; a formal scan would be beneficial.

The Bottom Line

ShellHub is a mature, Go‑based SSH gateway with a React/Tailwind UI. It offers all core SSH features and a clear separation between gateway and agent. The codebase is sizeable but well‑structured, with a strong test suite for the agent. Users must handle the .env file cautiously and may need to extend CI for full coverage. Overall, it is suitable for enterprises needing a single, auditable SSH entry point.