- Rust 96.4%
- Shell 2.5%
- Nix 0.6%
- Just 0.4%
| .claude | ||
| crates | ||
| nix | ||
| tests | ||
| .gitignore | ||
| .rustfmt.toml | ||
| AGENTS.md | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| flake.lock | ||
| flake.nix | ||
| justfile | ||
| README.md | ||
secuws
Secure ephemeral remote dev environments. secuws is a Rust CLI that rents a
cloud VM on demand, hardens it, live-syncs your working folder over a pinned SSH
channel, and runs Claude Code / other CLI agents / npm / build tooling only
on the VM — never on your laptop.
The laptop stays a near-inert client: it holds .git, runs git commit with
hooks disabled, forwards a TTY to agents running remotely, and talks to the VM.
The VM is the blast radius. When you're done, the VM is destroyed.
Why: the threat is malicious npm/PyPI packages (supply-chain) and AI agents running with broad permissions (
--dangerously-skip-permissions-style). If a dependency or an agent is hostile, it can corrupt the VM — but it cannot reach the laptop, cannot persist (the VM is deleted), and cannot escalate past its per-project non-root Linux user.
Contributors and AI agents working in this repo: read AGENTS.md
for architecture, invariants, and the build/test workflow.
Threat model (short version)
- Hostile npm/PyPI/etc. dependency → can compromise the rented VM, not the laptop.
- Hostile agent run → blast radius is the per-project non-root Linux user on the ephemeral VM. (There is no inner per-process sandbox by design — the VM + session user + teardown is the isolation.)
- The VM is ephemeral: deleted on teardown, and tagged + TTL-reaped by
secuws gcif the CLI dies before it can tear down. - The SSH host key is pinned on first connect (TOFU); every later connection refuses on mismatch (MITM guard).
.gitlives only on the laptop and is never synced. Push happens laptop-side with your real credentials — the VM never sees them.- Named secrets ship to the agent's process env only (
SECUWS_*SendEnv → a remote wrapper renames + unsets them) — never to disk, never to.git.
How it works (multi-host model)
secuws drives any number of shared hosts — say an Apple VM on your Mac, a
Firecracker VM on your home PC and a Hetzner server — each refcounted by the projects bound to it:
secuws upin a project folder asks where it should run: reuse one of the hosts that are up, or rent a new one (--host <name>/--new-hostanswer it up front). The firstupsimply provisions a host.- Every project on a host gets a session: a non-root Linux user, its own group
secuws-<project>, and its own synced tree at/srv/secuws/<project>. A project lives on exactly one host. secuws downremoves this project's session. Its host is destroyed only when its last project leaves;down --host <name>destroys one host,--allevery host.secuws host ls|rename|ttl|shell|rmmanages them.
LAPTOP (trusted, zero project exec) RENTED VM (ephemeral blast radius)
┌────────────────────────────┐ ┌───────────────────────────────────┐
│ secuws CLI / TUI (Rust) │ SSH (pinned │ secuws-helperd (root, systemd) │
│ · .git lives ONLY here │ host key, │ · line-JSON RPC over unix socket │
│ · git commit, hooks OFF │ ed25519 per │ · session/user manager │
│ · Mutagen sync supervisor │ host) │ · apt-get installer │
│ · ssh ctrl-master + -L/-R │◄─────────────►│ │
│ · TTY-forwards agents │ RPC + sync │ user sws-<projA>-xxxx /srv/.../A │
│ · NO node/npm/python here │ + ports + TTY│ └─ claude / aider / codex / … │
└────────────────────────────┘ │ user sws-<projB>-yyyy /srv/.../B │
└───────────────────────────────────┘
Firecracker: a VM on your own Linux box (or home PC)
Instead of renting a server, the shared host can be a Firecracker microVM on
a Linux machine with KVM — the laptop itself, or a home PC reached over ssh. A
small root daemon there, secuws-vmd, runs the VMs: each under jailer (own
uid, chroot, cgroup, pid namespace, seccomp), on its own copy of a base image
that is built inside a Firecracker VM (no Docker/podman), behind a host
firewall that lets guests reach the internet and nothing else (not your LAN,
not the host, not each other).
The KVM host needs only nftables and e2fsprogs beyond a base system
(NixOS: environment.systemPackages = with pkgs; [ nftables e2fsprogs ];).
Firecracker itself is downloaded by vmd, checksum-pinned.
# Home PC: pins its ssh key (you confirm the fingerprint), uploads + verifies
# the daemon, `sudo install-self` there, builds the guest image (~1-2 min).
ssh-add # the jump connection can't prompt
secuws vmd install --host max@192.168.178.44 --name home
secuws up --provider firecracker # VM reached through the home PC
# …or this machine (Linux + KVM):
secuws vmd install
secuws up --provider firecracker --location local
secuws vmd status / ls / prepare --rebuild # daemon health, VMs, fresh packages
On NixOS install prints the module snippet that keeps the service across
reboots. VMs survive daemon restarts and come back after a host reboot. Re-run
secuws vmd install after upgrading secuws to upgrade the daemon.
Nix
The flake.nix builds the CLI with both helperds and secuws-vmd
embedded (static musl, cross-built with rust-lld — works from macOS, no Docker),
and ships modules for NixOS / nix-darwin.
nix run github:devmaxde/secuws -- --version # try it
nix profile install github:devmaxde/secuws # install on any Mac / Linux
# flake inputs
inputs.secuws.url = "github:devmaxde/secuws";
# NixOS or nix-darwin: the CLI (+ ssh, git, mutagen)
imports = [ inputs.secuws.nixosModules.secuws ]; # darwin: darwinModules.secuws
programs.secuws.enable = true;
# NixOS x86_64 KVM host: the Firecracker daemon (replaces `secuws vmd install`'s
# sudo step; still run `secuws vmd install --host …` once from the laptop to pin
# the host key and register it)
imports = [ inputs.secuws.nixosModules.secuws-vmd ];
services.secuws-vmd = {
enable = true;
users = [ "max" ]; # who may drive it (group secuws-vmd)
prepare = true; # build the guest image at boot
# settings.subnet = "10.213.7"; # if 172.30.0.0/24 clashes with your LAN
};
The daemon runs from its fixed path /var/lib/secuws-vmd/bin/secuws-vmd, seeded
from the Nix package whenever that changes. A laptop whose embedded vmd differs
(by hash — e.g. a macOS build of the same commit) still upgrades it over sudo
as usual; that binary stays until the next package change. Avoid
networking.nftables.enable: its reloads flush vmd's firewall table.
Build
The CLI embeds a Linux/musl secuws-helperd binary (sha256-pinned for
server-side verification). The justfile automates the two-step
build; you should not invoke cargo for the CLI directly.
Prereqs
- Rust 1.88+ (workspace MSRV — see
Cargo.toml; raised from 1.83 byratatui0.30). just.- A C toolchain with
cmake+nasmonPATH—reqwest0.13's default rustls provider isaws-lc-rs, whoseaws-lc-syscrate builds its C sources at compile time. (apt install cmake nasm,brew install cmake nasm.) - A way to cross-build the helperd for
x86_64-unknown-linux-musl— either:cross(default):cargo install cross+ a running Docker/Colima, or- native:
rustup target add x86_64-unknown-linux-musl+ a musl linker (brew install filosottile/musl-cross/musl-cross), then build withBUILDER=cargo.
Common recipes
just build # release: cross-build helperd, then CLI with it embedded
just run up # run the debug CLI with a freshly-embedded helperd
just tui # open the TUI (debug)
just install # build release + copy to ~/.cargo/bin/secuws
just test-unit # cargo test --workspace
just test-live # helperd ⇄ secuwsd ⇄ MCP against a local unprivileged helperd (no VM)
just test # unit + the live Hetzner integration test (costs ~€0.02)
just check # cargo check --workspace
just clippy # lint
just fmt # rustfmt all crates
build.rshard-fails in every profile when no helperd is given (SECUWS_HELPERD_BIN_X86_64/SECUWS_HELPERD_BIN_AARCH64) — asecuwsthat can't ship a helperd is useless, and the TUI must not start without one. Thejustrecipes set it for you. Plaincargo build -p secuws-cliwill fail by design; usejust.
Release output: target/release/secuws — a single laptop binary with the
verified helperd payload inside (~14 MB).
Quick start (after just install)
# 1. Stash secrets in your OS keyring (no echo; --from-stdin for CI).
secuws auth hetzner
secuws auth anthropic # optional; used as --with-secret anthropic-key
# 2. One-time global config wizard (provider, region, server type, TTL).
secuws init
# 3. In a project folder: provision (or reuse) the host + bind this project.
# Mints a per-host ed25519 key, pins the VM host key, uploads + sha256-
# verifies helperd, opens the control-RPC forward, starts Mutagen sync.
# `.git` and `.secuws/` are never synced. Finishes by applying
# `.secuws/setup.toml` so your dependencies are installed before you shell in.
secuws up
# 4. Inspect host + sessions + forwards + helperd liveness.
secuws status
# 5. Drop into a shell as this project's non-root session user (in /srv/secuws/<project>).
secuws shell # add --root for the privileged `secuws` user
# 6. Run any CLI agent on the VM with a TTY forwarded from the laptop.
# Secrets are injected into the agent's process env only — never disk.
secuws agent run --with-secret anthropic-key -- claude
# …or launch a cataloged agent with persistent login: `launch` installs it
# if missing, re-seeds your saved login, runs it, and snapshots the login
# back to the laptop on exit. Authenticate once (e.g. a Claude subscription /
# `claude login`); every later launch — in a NEW session or on a FRESH host —
# reuses it, so you never re-auth. Works for any cataloged agent.
secuws agent default claude-code # once per project: pick the default agent
secuws agent launch # restore login → run → save login on exit
secuws agent launch --no-save-login # opt out of saving for this one run
# 7. Commit from the laptop with hooks neutralised. Push as normal `git push`.
secuws commit -- add .
secuws commit -- commit -m "wip"
# 8. Leave: removes THIS project's session. The VM is destroyed only when the
# last project leaves (or now, with --all).
secuws down # add --all to force-destroy the whole host
Cost guard — if the CLI ever dies before teardown:
secuws gc # list secuws-tagged servers past TTL (dry run)
secuws gc --delete # actually reap them
Handing tasks to agents from another AI (MCP)
secuws ships an MCP server, so an external AI system (Claude Code, Claude
Desktop, any MCP client) can hand tasks to the agents in your projects. It runs
through secuwsd, the background daemon that owns your host connection, and
every task goes through the target project's task policy — exactly like an
agent's own secuws-task.
# 1. A token for the client (shown once). Tasks from it arrive as `ext:my-ai`.
secuws daemon token create my-ai # scopes: read + tasks (default)
# 2. Let a project accept it. `*` never covers external clients — name them.
secuws agent policy set --project web --allow-source ext:my-ai --unattended auto
# 3. Point the AI client at it, e.g. Claude Code:
claude mcp add secuws -e SECUWS_MCP_TOKEN=<token> -- secuws mcp
Tools: list_projects, host_status, agent_status, submit_task (optionally
waiting for the answer), wait_task, get_task, list_tasks, cancel_task,
project_diff, and — only with a lifecycle token — project_up /
project_down / get_job. A token client sees only its own tasks. Answers are
written by an AI agent working in that project; the MCP server says so, and a
client should treat them as untrusted input.
From a terminal the same path is secuws task submit -p web --wait 600 "…".
Command reference
| Command | Purpose |
|---|---|
up [--host <name> | --new-host [<name>]] [--provider <p>] [--location <r>] [--server-type <t>] [--ttl-hours <h>] [--project <n>] [--image <i>] [--no-sync] |
Bind this project to a host — asks reuse which host / new host unless --host/--new-host (or a provider option) decides; a new host is provisioned with its own TTL. Binds this project as a session; start sync; then apply .secuws/setup.toml (install dependencies) as the final step. |
down [--yes] [--host <name> | --all] [--force] |
Remove this project's session; destroy its host when it was that host's last project. --host destroys one host, --all every host, --force only clears the local record (VM already gone). On host destroy, also reaps orphaned secuws- SSH keys from the provider account. |
status / ls [--no-helperd] |
Show every host (TTL, bound projects, helperd liveness), then this project's forwards + sync. |
host ls / host rename <old> <new> / host ttl <name> <hours> / host shell <name> / host rm <name> [--yes] [--force] |
The hosts you drive: list, rename (local name), set the TTL (0 = never), root shell, destroy. |
shell [<session>] [--root] [--host <name>] |
Interactive shell — defaults to this project's session user on its host; --root = privileged secuws user; --host picks another host. |
session create|ls|rm <name> |
Manage extra agent-lane sessions (non-root users) on the host. |
pkg add <name> [--session <s> --via "<installer>"] |
System-tier (apt-get via helperd) or user-tier (--via, runs as the session user). |
setup [--session <s>] [--start-forwards|--no-forwards] |
Apply the project's .secuws/setup.toml (batch installs), then offer the .secuws/forwards.toml port forwards (autostart silently / one Y/n prompt). |
port add --to-local <spec> | --to-remote <spec> [--save|--no-save] |
Open an ssh -L / -R forward (held by a detached process); offer to persist it to .secuws/forwards.toml. |
port ls / port rm <index> |
List (with end-to-end health) / close forwards. |
port check [--fix] |
Probe forwards end-to-end; --fix respawns STALE/DEAD ones (e.g. after laptop sleep). |
sync status|pause|resume|flush|restart |
Live sync state (staging %, conflicts); pause/resume transfer; flush; restart to re-apply ignores. |
agent run [--session <s>] [--with-secret name[=ENV]]… -- <cmd…> |
Run any CLI agent on the VM with a TTY forwarded; inject keyring secrets to process env. |
agent ls / agent default <id> |
List the built-in agent catalog (★ default, [login saved]); set this project's default. |
agent launch [<id>] [--no-save-login] [--dangerously-skip-permissions|--safe] |
Install-if-missing, restore saved login/skills, run with a TTY, then snapshot the login back to the laptop on exit (persistent login). --no-save-login opts out of the save. |
agent install|pull|push [<id>] [--session <s>] |
Install the agent; snapshot its login/skills to the laptop; or re-seed a saved snapshot onto the VM. |
agent approvals |
Review + approve/deny pending secuws-sudo root-command requests. |
agent tasks |
Review pending secuws-task delegations; on approval, run the target project's agent to handle the prompt. |
commit -- <git args> |
Run git in the project dir with hooks/fsmonitor/filters neutralised. |
gc [--delete] [--ttl-hours <n>] |
Reap secuws-tagged servers past TTL on every provider in use (cost guard; a recorded host goes by its own TTL, --ttl-hours covers unrecorded orphans) and, with --delete, orphaned secuws- SSH keys. |
vmd install [--host user@host[:port]] [--name <n>] / vmd status [<n>] / vmd ls / vmd prepare [<n>] [--rebuild] / vmd forget <n> |
Firecracker: install/upgrade secuws-vmd on a KVM host (pins a remote host's key), check it, list its VMs, (re)build its guest image, forget a host. |
auth hetzner|anthropic|set <name>|unset <name> |
Manage OS-keyring secrets. |
init |
Interactive wizard to write the global config. |
tui |
Open the ratatui cockpit (also available as the secuws-tui binary). |
daemon run|start|status|stop|logs |
The secuwsd control daemon the TUI, CLI and MCP server share. Starts on demand; these manage it explicitly. |
daemon token create <name> [--scope read|tasks|lifecycle]… / token ls / token rm <name> |
Client tokens for integrations (the MCP server). Tasks from a token client arrive as ext:<name>. |
task submit -p <project> [--wait <s>] <prompt…> / task get|wait|ls|cancel|watch |
Hand a task to a project's agent through the daemon and follow it (attributed ext:cli). |
mcp / mcp config [<name>] |
Serve the Model Context Protocol on stdio (needs SECUWS_MCP_TOKEN); print a client config snippet. |
On-disk layout
| Path | Holds |
|---|---|
<config_dir>/config.toml |
provider, region, server type, ttl_hours |
<config_dir>/host/hosts.json |
every host: its name, ServerRecord (incl. its TTL) + the active project list (refcount) |
<config_dir>/host/<name>/keys/ |
that host's ephemeral ed25519 private key |
<config_dir>/projects.json |
global project registry (for the TUI's project list) |
<config_dir>/vmd-hosts.json |
Firecracker KVM hosts (secuws vmd install): local or user@host:port + its pinned ssh host key; the default for --location auto |
<config_dir>/daemon/ |
secuwsd: its socket (secuwsd.sock, 0600), log, task results (tasks.json, 0600) and client-token hashes (tokens.json) |
<project>/.secuws/state.json |
project-local: port forwards + mirrored sessions (gitignored) |
<project>/.secuws/.gitignore |
auto-generated — ignores all of .secuws/ except the manifests |
<project>/.secuws/setup.toml |
package manifest — checked in alongside the project |
<project>/.secuws/forwards.toml |
predefined port forwards, offered on secuws setup — checked in |
<project>/.secuws/syncignore |
gitignore-syntax sync overrides (re-include a .gitignore'd dev/env file, or add a sync-only ignore) — checked in |
<config_dir> is OS-native via the directories crate — on macOS,
~/Library/Application Support/dev.secuws.secuws/. Secrets (provider token,
Anthropic key, named secrets) live in the OS keyring, never on disk.
Repository layout
crates/
secuws-cli/ laptop binary `secuws`; embeds the cross-built helperd
secuws-tui/ ratatui cockpit (also `secuws tui`)
secuws-client/ control-machine plumbing: helperd client, secuwsd API + client, tokens
secuws-daemon/ secuwsd: helperd link, event ring, task store, control API
secuws-mcp/ `secuws mcp`: MCP server over the secuwsd API
secuws-helperd/ VM-side privileged daemon (line-JSON RPC; audit log)
secuws-vmd/ root daemon on a Linux KVM host: Firecracker VMs, in-VM image build, host egress firewall
secuws-guest/ the guest image context (Dockerfile, provision.sh, init scripts), embedded
secuws-proto/ shared RPC types (PROTO_VERSION + tagged Request/Response)
secuws-provider/ Backend trait + Hetzner impl (raw reqwest, no SDK) + Apple `container` impl + Firecracker (via secuws-vmd)
secuws-transport/ ssh-keyscan TOFU, pinned-host-key SshSession, -L/-R forwards
secuws-sync/ Mutagen wrapper (`.git` + `.secuws` always excluded)
secuws-core/ config, host/runtime state, registry, secrets, keys, ports, forwards, cloud-init
tests/
integration_test.sh opt-in live Hetzner end-to-end test
fixtures/rust-webserver/ fixture project (+ a sample .secuws/setup.toml)
justfile build/test task runner
License
MPL-2.0. See the workspace Cargo.toml.