Skip to content

feat(dev-box): SSH dev box for dstack v0.6 CVMs - #169

Open
h4x3rotab wants to merge 1 commit into
mainfrom
add-dstack-host-ssh-compose-example
Open

h4x3rotab wants to merge 1 commit into
mainfrom
add-dstack-host-ssh-compose-example

Conversation

@h4x3rotab

Copy link
Copy Markdown
Contributor

Summary

dstack v0.6 no longer ships a dev OS image, so CVMs have no SSH or debugging tools. This adds dev-box/, a single container you drop into any compose file to get them back.

  • SSH: sshd on port 1022, root login with public keys only. Keys come from the encrypted SSH_AUTHORIZED_KEYS env var, and the container refuses to start without them. Reach it through dstack-gateway with the usual openssl s_client ProxyCommand.
  • Tools: a Debian trixie userland, the same base as the 0.6 guest OS: rsync, sftp/scp, vim, tmux, gdb, strace, tcpdump, htop, jq, dig, python3, and the Docker CLI with compose. apt-get install works for anything else.
  • Host access: shares the host's PID, network and UTS namespaces. The host root is mounted at /host, and docker drives the host daemon.
  • host-shell: runs nsenter into every namespace of host PID 1 for a real host shell (systemctl, journalctl, …). host-shell CMD runs a single command on the host.

The host rootfs is read-only and dm-verity-protected, so tools can't be installed on it. The box brings its own userland and borrows the host's namespaces instead, the same design as Bottlerocket's admin container and kubectl debug node.

.github/workflows/build-dev-box.yml builds ghcr.io/dstack-tee/dstack-dev-box, following the tsm-shim workflow: it only builds on PRs and pushes on main.

Warning

This gives full root on the CVM and breaks confidentiality. It's for development only, and the README says so up front.

Test plan

Deployed on Phala Cloud prod15 with dstack-0.6.1, using an image pushed to ttl.sh:

  • SSH through <app-id>-1022.dstack-pha-prod15.phala.network:443
  • Box sees host PID 1 (systemd), the host network interfaces (dstack-wg0) and the hostname dstack
  • /host shows the 0.6.1 rootfs and /host/dstack/app-compose.json
  • docker ps and docker compose version work against the host daemon (26.1.5 on both ends)
  • host-shell gives the host's bash in /root with a working terminal, sharing PID 1's mount namespace; host-shell journalctl -u docker works
  • scp, sftp and rsync work in both directions
  • /root contents and the SSH host key survive a container restart
  • ./dev.sh check-all passes, and shellcheck is clean on the new scripts

🤖 Generated with Claude Code

dstack v0.6 drops the dev OS image, so there is no built-in SSH or
debugging toolset on the CVM anymore. Add a single container that
brings them back:

- sshd on port 1022 (public-key root login, keys from the encrypted
  SSH_AUTHORIZED_KEYS env), reachable through dstack-gateway
- Debian trixie userland matching the 0.6 guest OS: rsync, sftp, vim,
  tmux, gdb, strace, tcpdump, htop, docker CLI + compose, ...
- shares the host PID, network and UTS namespaces; host root at /host;
  host Docker daemon via docker.sock
- host-shell: nsenter into every namespace of host PID 1 for a real
  host shell (systemctl, journalctl, ...)

/dev/pts is shared with the host so PTYs stay valid after host-shell
switches mount namespaces. The SSH host key and /root persist in
volumes.

Tested on Phala Cloud prod15 with dstack-0.6.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant