{"slug": "show-hn-bastion-self-hosted-vms-for-background-coding-agents", "title": "Show HN: Bastion – self-hosted VMs for background coding agents", "summary": "Bastion, an open-source orchestrator for running background coding agents on self-hosted Linux infrastructure, was released. Each agent runs in a separate Cloud Hypervisor VM with a reproducible dev environment, supporting declarative setup, prepared snapshots, and multi-node clustering. The tool aims to simplify scaling coding agents with VM-level isolation and direct access via SSH or a TUI.", "body_md": "**Self-hosted virtual computers for background coding agents.**\n\n[Website](https://bastion.computer/) ·\n[Docs](https://bastion.computer/introduction/) ·\n[Quick start](https://bastion.computer/quick-start/) ·\n[Demo](https://github.com/bastion-computer/bastion-demo) ·\n[Discussions](https://github.com/orgs/bastion-computer/discussions)\n\nBastion is an open-source orchestrator for running background coding agents on your own Linux infrastructure. Each agent runs in a separate [Cloud Hypervisor](https://www.cloudhypervisor.org/) VM with a reproducible dev environment.\n\nDefine an environment in JSON, prepare it once as a snapshot, and create disposable VMs for parallel tasks. Bastion can run on a single KVM host or schedule environments across an optional multi-node cluster.\n\nBastion makes it easy to scale background coding agents into reproducible environments.\n\n**VM-level isolation:** each environment has its own guest kernel, root filesystem, processes, and network.**Declarative setup:** define CPU, memory, disk, agents, service tunnels, and lifecycle actions in schema-validated JSON.**Prepared snapshots:** install dependencies during template creation, then replicate isolated copy-on-write environments from that prepared state.**Direct access:** connect through SSH, attach a local OpenCode TUI, or use`bastion mux`\n\nto move between persistent sessions.**Conflict-free previews:** expose dev servers on the guest VM through named tunnels for host side previews.**Self-hosted control:** start on one Linux machine, then add the cluster control plane when a single host is not enough.\n\nThe host needs:\n\n- Linux on x86_64\n- read/write access to\n`/dev/kvm`\n\n`/dev/vhost-vsock`\n\nfor VM tunnel traffic- nested virtualization when the host is itself a VM\n\n```\ncurl -fsSL https://bastion.computer/install.sh | bash\n\nbastion system check\nbastion system init --with-utilities\n```\n\nThe installer adds the `bastion`\n\nCLI, guest proxy, and systemd services for the host API and privileged VM daemon. Release archives are also available from [GitHub Releases](https://github.com/bastion-computer/bastion/releases).\n\n```\ncat > template.json <<'JSON'\n{\n  \"resources\": {\n    \"vcpu\": 2,\n    \"memory\": 2,\n    \"volume\": 20\n  },\n  \"agents\": {\n    \"opencode\": {}\n  },\n  \"actions\": {\n    \"init\": [\n      {\n        \"run\": \"mkdir -p /workspace && printf 'hello from Bastion\\\\n' > /workspace/README.md\"\n      }\n    ]\n  }\n}\nJSON\n\nbastion templates create --key hello --file ./template.json\n```\n\nTemplate creation boots a temporary VM, runs `actions.init`\n\n, and stores an immutable prepared root disk and VM snapshot.\n\n```\nbastion env create --template-key hello --key agent-1\nbastion ssh --key agent-1 -- cat /workspace/README.md\nbastion ssh --key agent-1\n```\n\nWith OpenCode installed locally, attach its TUI to the server inside the environment:\n\n```\nbastion opencode --key agent-1\n```\n\nOr open Bastion's tmux-based environment picker:\n\n```\nbastion mux\n```\n\nClean up when finished:\n\n```\nbastion env remove --key agent-1\nbastion templates remove --key hello\n```\n\nFor a complete parallel-agent walkthrough, see the [Bastion issue tracker demo](https://github.com/bastion-computer/bastion-demo). It includes a Bun/TypeScript app, a reusable environment template, service previews, and five independent coding tasks.\n\n``` php\nflowchart LR\n    Client[\"CLI / API client\"] --> API[\"Host API<br/>unprivileged · SQLite\"]\n    API -->|Unix socket| Daemon[\"bastiond<br/>privileged VM operations\"]\n    Daemon --> VM1[\"Cloud Hypervisor VM<br/>agent-1\"]\n    Daemon --> VM2[\"Cloud Hypervisor VM<br/>agent-2\"]\n    Daemon --> VMN[\"Cloud Hypervisor VM<br/>agent-n\"]\n```\n\nThe local control plane is split into two processes:\n\n`bastion start api`\n\nstores metadata, serves the HTTP API on`localhost:3148`\n\nby default, and runs without root privileges.`bastion start daemon`\n\nperforms privileged Cloud Hypervisor operations behind a Unix socket.\n\nWhen a template is created, Bastion boots a temporary VM, runs the ordered `actions.init`\n\nsteps, pauses it, and saves its prepared disk and VM snapshot. Creating an environment restores that snapshot, adds a small qcow2 writable overlay, runs optional `actions.start`\n\nsteps, and exposes SSH, OpenCode, and configured service tunnels through the API.\n\nFor multiple hosts, the optional cluster API stores shared state in Postgres, stores prepared template archives in S3-compatible object storage, schedules environments onto registered nodes, and proxies connections to the node that owns each environment.\n\nThis example prepares a Bun project once, refreshes it whenever an environment starts, and exposes its development server:\n\n```\n{\n  \"resources\": {\n    \"vcpu\": 4,\n    \"memory\": 8,\n    \"volume\": 40\n  },\n  \"tunnels\": {\n    \"web\": 3000\n  },\n  \"agents\": {\n    \"opencode\": {\n      \"working_directory\": \"/workspace/project\"\n    }\n  },\n  \"actions\": {\n    \"init\": [\n      {\n        \"use\": \"setup_bun\"\n      },\n      {\n        \"run\": \"git clone https://github.com/your-org/your-repo.git project\",\n        \"working_directory\": \"/workspace\"\n      },\n      {\n        \"run\": \"bun install\",\n        \"working_directory\": \"/workspace/project\"\n      }\n    ],\n    \"start\": [\n      {\n        \"run\": \"git pull --ff-only\",\n        \"working_directory\": \"/workspace/project\"\n      },\n      {\n        \"run\": \"nohup bun run dev >/tmp/dev-server.log 2>&1 &\",\n        \"working_directory\": \"/workspace/project\"\n      }\n    ]\n  }\n}\nbastion templates create --key project --file ./template.json\nbastion env create --template-key project --key issue-123 --tag repo:project\nbastion proxy --env-key issue-123 --name web\n```\n\nSee the [template guide](https://bastion.computer/guides/templates/) and [public JSON schema](https://bastion.computer/schemas/template.json) for the complete format.\n\n- VM hosts currently need Linux x86_64, KVM, and vhost-vsock. macOS Apple silicon is client-only.\n`bastiond`\n\nruns as root because it manages VM lifecycle and networking operations. Template actions run as root inside the guest.- The host API binds to\n`localhost:3148`\n\nby default. Anyone who can reach it can create, remove, and enter environments, so keep it private or place it behind your own authenticated network and TLS boundary. - OpenCode is the built-in agent integration today; SSH is available for other tools and workflows.\n- The project is pre-1.0, and interfaces may still change.\n\nStart with the [introduction](https://bastion.computer/introduction/) and [quick start](https://bastion.computer/quick-start/), then see the guides for [system setup](https://bastion.computer/guides/system/), [templates](https://bastion.computer/guides/templates/), [environments](https://bastion.computer/guides/environments/), and [clustering](https://bastion.computer/guides/cluster/). The site also includes complete [CLI](https://bastion.computer/reference/cli/) and [API](https://bastion.computer/reference/api/) references.\n\nQuestions, bug reports, design feedback, and use cases are welcome in [GitHub Discussions](https://github.com/orgs/bastion-computer/discussions) or by email at [hazim@bastion.computer](mailto:hazim@bastion.computer).\n\nBastion is available under the [MIT License](/bastion-computer/bastion/blob/main/LICENSE.md).", "url": "https://wpnews.pro/news/show-hn-bastion-self-hosted-vms-for-background-coding-agents", "canonical_source": "https://github.com/bastion-computer/bastion", "published_at": "2026-07-07 13:22:12+00:00", "updated_at": "2026-07-07 13:29:56.030830+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "ai-infrastructure"], "entities": ["Bastion", "Cloud Hypervisor", "OpenCode", "Linux", "KVM", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/show-hn-bastion-self-hosted-vms-for-background-coding-agents", "markdown": "https://wpnews.pro/news/show-hn-bastion-self-hosted-vms-for-background-coding-agents.md", "text": "https://wpnews.pro/news/show-hn-bastion-self-hosted-vms-for-background-coding-agents.txt", "jsonld": "https://wpnews.pro/news/show-hn-bastion-self-hosted-vms-for-background-coding-agents.jsonld"}}