A single static binary. Zero external dependencies. Copy and run. Securely expose directories across multiple servers to your local agents — OS account provisioning + per-directory ACL grants + an MCP credential directory.
English · English Guide · 中文说明 · 中文指南
Local assistant agents often work across many servers at once (read/write repos, inspect logs, edit configs) — but handing them a root password is unsafe and unauditable. DirGate is the permission foundation for that workflow:
- Admins register servers in a Web UI, provision least-privilege OS accounts for agents, and grant per-directory
rw/roACLs; - Agents fetch the full "server + account + directory list" through a single MCP tool, then work only inside granted directories — anything beyond the boundary is rejected at the OS level;
- Grants can carry an expiry: exposure vanishes from MCP automatically and the remote account gets locked.
The core idea: authorization as the boundary. Real access control is enforced by POSIX ACLs on the servers; the platform only handles provisioning and revocation.
Prebuilt binaries (linux/darwin/windows, amd64+arm64) are on the Releases page — download, chmod +x, run. No Go needed.
Otherwise, build requires Go 1.26+: (the result is a single static binary — target machines need nothing but the binary and SSH access to the servers being managed; target servers need the acl package).
# Server side (any Linux host)
./run.sh # generates .env → builds single binary → starts; random admin password in data/admin-password.txtOpen http://localhost:8080/login: add a server → create or attach accounts (real OS users + per-directory ACLs) → flip the "Expose" switch → optionally set an expiry.
# Agent side (one call, cache into agent context)
curl -s -H "Authorization: Bearer $DG_MCP_TOKEN" \
-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_exposed_accounts","arguments":{}}}' \
http://sal-host:8080/mcp
# Or attach the streamable HTTP endpoint in any MCP-capable agent, then work inside granted directories:
sshpass -p '<password>' ssh coder1@10.0.0.5 'cd /data/repo && <any command>'Driving Claude Code is one example: run claude -p "<task>" inside a granted directory — the platform doesn't care what runs there.
The same binary ships a ctl subcommand that drives a running service over its REST API — no UI, no config edits:
export DG_SERVER_URL=http://127.0.0.1:18080 # or set DG_LISTEN_ADDR; default http://127.0.0.1:8080
export DG_ADMIN_PASSWORD=... # admin login
export DG_MCP_TOKEN=... # only for `exposed`
dirgate ctl servers # list servers
dirgate ctl server-add dev1 10.0.0.5 'root-password' 22 root prod # add (tag: prod)
dirgate ctl server-test <id> # probe root/sudo/plain tier
dirgate ctl account-add <id> coder1 'pass' '/data/repo=rw,/logs=ro' '2026-12-31T23:59:59+08:00'
dirgate ctl account-expose <account-id> on # exposure switch
dirgate ctl exposed # agent's view (passwords masked)dirgate ctl prints all 14 commands. Writes share the same API and audit trail as the Web UI. Full reference: the CLI section in the Guide.
- Real provisioning:
useradd/chpasswd/setfacl/userdelexecuted for real; non-root admin accounts escalate viasudo -nautomatically - Per-directory ACLs:
rw/rogrants include default ACLs (inherited by new files); ACLs revoked directory-by-directory before account deletion — no orphans - Expiry & reclamation:
expires_at→ MCP exposure stops immediately → remote account locked (data preserved; renew + re-provision to restore) - MCP directory:
list_exposed_accountsreturns only exposed, non-expired accounts on enabled servers - Secure defaults: AES-256-GCM credentials at rest, argon2id admin hash, HMAC sessions + CSRF + login rate limiting, SSH TOFU fingerprints, operation audit log
- Trivial deployment: single static binary (pure Go, no cgo), SQLite with versioned auto-migrations, embedded Web UI, systemd unit and backup script included
- Guide · 指南(中文) — environment variables, API reference, MCP onboarding, security model, backup/restore, troubleshooting
- deploy/ — systemd unit template and backup script
- .env.example — annotated configuration reference
go test ./... # unit tests
go test -tags integration ./internal/sshx/ # real sshd integration tests (needs docker)