sshd: implement --ssh.enable with a pure-Go OpenSSH server#6
Merged
Conversation
The M4 stub only logged "ssh requested" — no server, so rescue sessions couldn't connect. Now `--ssh.enable` runs a pure-Go OpenSSH server (golang.org/x/crypto/ssh + github.com/creack/pty) inside the pivoted rootfs. - Ephemeral ed25519 host key; fingerprint logged. - Auth: public keys parsed from --ssh.authorized-keys (standard authorized_keys format, one per line; blank + comment lines skipped) OR password from --ssh.password. Both accepted when both set. Server refuses to start with neither configured. - Sessions: pty for interactive shell (pty-req + shell), plain pipes for exec. TERM, env vars, and window resizes propagated. - All sessions run /bin/sh as root — the rescue rootfs has no user db. Linux-only; non-Linux stub returns "not supported." Follow-ups (separate PRs): --ssh.tailscale-auth to bind on the tsnet listener + WhoIs-check tailnet peer identity (no ACL parsing yet).
This was referenced Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--ssh.enablewas a stub (slog.Info(\"ssh requested\")), so rescue sessions couldn't actually connect. Now it runs a pure-Go OpenSSH server (golang.org/x/crypto/ssh + github.com/creack/pty) inside the pivoted rootfs.--ssh.authorized-keys(standardauthorized_keysformat, one per line; blank + comment lines skipped) OR password from--ssh.password. Both accepted when both set; server refuses to start with neither.pty-req+shell→ interactive/bin/sh -lin a real pty (creack/pty);exec→ non-pty/bin/sh -c \"…\". TERM,envrequests,window-changeall propagated.Linux-only; non-Linux stub returns "not supported" (pty + os/exec shell handling needs Linux semantics).
Motivation
Ran a real pivot into a
coreos-installerimage today. The tsnet node registered on the tailnet but SSH timed out — tsnet doesn't ship the Tailscale SSH server, and xmorph's own--ssh.enablewas a no-op. No way to observe the install; had to power-cycle when things went sideways.Test plan
go test ./internal/postpivot/... ./internal/config/... ./internal/cli/...on Linux (endeavour): all pass.--ssh.enable --ssh.authorized-keys ...; confirm we can SSH into the pivoted env and observe install progress.Follow-ups (out of scope)
--ssh.tailscale-auth: bind on the tsnet listener and useLocalClient().WhoIs()to identify the peer, trust any tailnet member (no ACL parsing yet)./etc/xmorph/ssh_host_ed25519_key) so known_hosts entries survive multi-pivot fleets.