mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
Docker VMs get ssh for editors, listed ports, every port, agent forwarding and agent toggling, all over one transport: devvm's ssh config reaches a VM through `devvm _docker-connect`, which runs `sshd -i` in the labelled container by ID with docker exec. The container publishes nothing and runs no listening sshd. - internal/backend/vmssh: VM keys, host-key parsing, the port forwarder and its processes, shared by smolvm and docker - `devvm _docker-ports`: every port, or the listed ones; ports a host program has are skipped (ports_taken) - the agent goes only to ssh sessions (ForwardAgent, IdentityAgent); no socket is mounted - --clone on Docker, its clone in a per-VM volume - platform.ListenExclusive keeps SO_REUSEADDR on Linux; UsedPorts leaves out the VM's own listed ports - messages: vm_no_ssh, vm_no_sshd, ports_no_ssh, ports_forward_failed, forwarder_failed, docker_ssh_path, docker_connect_failed - reviewed: design notes and threat check in design.md; e2e checks for a hostile sshd config, host ports kept on every address family, and ports not forwarded off loopback or listed by another VM Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 lines
1.0 KiB
Bash
Executable File
27 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Stand-in for ssh in tests: host git pushing to and fetching from a --clone
|
|
# VM. Logs every call to $STUB_LOG, and runs the git command it's given
|
|
# here, on $STUB_DIR/vmfs/DIR (the VM's files, as the limactl stub keeps
|
|
# them). With $STUB_DIR/ssh-fails, or for anything else, it fails as ssh
|
|
# does. A login shell in a folder (a Docker VM's shell over ssh) reads its input and ends. A
|
|
# master connection (-M, a smolvm or Docker VM's port forwarder's) reads the script it's fed, answers it with $STUB_DIR/guest-ports (what listens in the VM, as /proc/net/tcp has
|
|
# it) and ".", then waits to be stopped.
|
|
set -euo pipefail
|
|
echo "ssh $*" >> "$STUB_LOG"
|
|
[[ ! -e $STUB_DIR/ssh-fails ]] || exit 255
|
|
if [[ " $* " == *" -M "* ]]; then
|
|
cat > /dev/null
|
|
[[ ! -f $STUB_DIR/guest-ports ]] || cat "$STUB_DIR/guest-ports"
|
|
echo .
|
|
exec sleep 300
|
|
fi
|
|
cmd=${*: -1}
|
|
case $cmd in
|
|
"git-receive-pack "* | "git-upload-pack "*)
|
|
eval "set -- $cmd"
|
|
exec git "${1#git-}" "$STUB_DIR/vmfs$2" ;;
|
|
"cd -- "*" && exec bash -l")
|
|
cat > /dev/null; exit 0 ;;
|
|
esac
|
|
exit 255
|