Paliadin: route prod via Tailscale SSH to mRiver (preserve Claude Code subscription) #12
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Route Paliadin from paliad.de's Dokploy container (mLake,
100.99.98.201) to mRiver (100.99.98.203) via Tailscale + SSH, so m can use Paliadin from prod without losing the Claude-Code-subscription benefit (vs paying Anthropic API tokens).Locked direction (m, 2026-05-07 22:33)
SSH-tunnel via Tailscale chosen over Anthropic API direct (preserves subscription) and over standalone HTTP daemon on mRiver (cleaner protocol but extra moving piece).
Concrete shape:
tmux new-session ...invocation forssh m@100.99.98.203 tmux ...when running on a host without local tmuxOut of scope (v1)
Open design questions (for inventor — m will engage)
Container Tailscale shape
network_mode: hostso paliad inherits host's Tailscale? Userspacetailscaledinside paliad's container with auth-key from secrets? Inventor recommends, m signs off..env.age? How is it rotated?sshclient + Tailscale binary. Inventor proposes the Dockerfile diff. Image-size impact?SSH identity + auth
.env.age?). Public key authorised on mRiver under~m/.ssh/authorized_keys.authorized_keysentry restricts tocommand="<paliadin-shim>"so the key can ONLY run the tmux invocation, not arbitrary shells. Define the shim shape.~/.ssh/known_hostspre-populated with mRiver's host key? OrStrictHostKeyChecking=accept-newfirst time? Inventor recommends.Service-layer integration
internal/services/paliadin.go: Where exactly does the tmux invocation happen? Does the SSH version share the same code path with a flag, or is there a separateRemotePaliadinServiceimplementation?PALIADIN_REMOTE_HOST=100.99.98.203? Auto-detect (try local tmux first, fall back to SSH)? Inventor recommends.ControlMaster auto?Reliability + monitoring
ssh -o ConnectTimeout=2? Cached health check?friendlyErrorMessageshape from t-150. Add error codemriver_unreachablewith localised message ("mRiver ist offline — Paliadin nicht erreichbar. Lokal mit./paliadstarten oder mRiver wecken.").Security + auth-domain
m. Mitigations: SSHcommand=restriction (Q5); audit log on mRiver-side; Dokploy host-disk encryption assumption.Phasing
PALIADIN_REMOTE_HOSTenv var.References
internal/services/paliadin.go— current local-tmux implementationdocs/design-paliadin-2026-05-07.md— original design (notes Phase 1 was "Anthropic API direct"; this issue introduces a third path)100.99.98.201(Dokploy host)100.99.98.203(m's laptop, runs Claude Code).env.agefor Dokploy secrets patternfriendlyErrorMessage) — pattern to extend formriver_unreachableInventor brief
mai/noether/inventor-paliadin-tailscale-sshdocs/design-paliadin-tailscale-ssh-2026-05-07.md. Three sub-designs:Inventor design pushed:
docs/design-paliadin-tailscale-ssh-2026-05-07.md(commitbefa41conmai/noether/inventor-paliadin).m's locked decisions (verbatim, 22:35):
network_mode: hoston paliad (overrode inventor's sidecar recommendation; Phase A gates rollout on traefik still routing under host mode)paliadin-shim(one RPC per turn:run-turn/reset/health/bootstrap)PALIADIN_REMOTE_HOST+Paliadininterface split (LocalPaliadinService↔RemotePaliadinService)PALIADIN_SSH_PRIVATE_KEY, chmod-600 tmpfile at startupVerified live before designing (so the design isn't built on stale CLAUDE.md):
100.99.98.203has tmux 3.6a + claude CLI at/home/m/.local/bin/claude100.99.98.201has Tailscale running, sees mRiveractive; direct [...]:41641~/.ssh/authorized_keysdoes NOT exist on mRiver yet — Phase A creates itThree-phase rollout:
+openssh-client), compose (host mode + 4 env vars), Go interface split, Dokploy secrets registration.mriver_unreachablefriendly error extending t-paliad-150, admin dashboard health probe.Three open questions for m at end of doc (§11): traefik+host-mode Dokploy doc check before B, shim location (repo vs mRiver-only), and the dead
ANTHROPIC_API_KEYcomment line in compose.Inventor stopped here. No code shipped. Awaiting m's go/no-go before coder shift.
Phase A.0 complete (coder shift, noether) — SSH path proven end-to-end on the tailnet.
Commits:
0248411shim,f952fb8design amendment.What changed from the original design
Tailscale SSH intercepts mRiver:22 — banner says
SSH-2.0-Tailscale, auth methodnone,authorized_keys command=directive never fires. Discovered while debugging "fish: Unknown command: health" on the first run-turn test.Fix: added a separate listen port
:22022via asystemd ssh.socketdrop-in. Tailscale SSH only intercepts:22, so:22022hits real OpenSSH wherecommand=/from=/no-pty/...work as specified. m's interactivetailscale ssh m@mriveron:22is untouched.(First attempt at the drop-in briefly failed with
Address already in use— a stalePort 22022directive from sshd_config was holding the port; reverted in ~30 s and retried clean. Documented in §4.5.)Verified live
State on mRiver (m's laptop) — already in place
/home/m/.local/bin/paliadin-shim(executable) — repo-version-controlled atscripts/paliadin-shim~/.ssh/authorized_keys— paliad-prod public key withcommand=/from="100.99.98.201"/no-pty/no-port-forwarding/no-agent-forwarding/no-X11-forwarding/no-user-rc/etc/systemd/system/ssh.socket.d/paliad.conf— port 22022 socket drop-in~/.paliad-staging/— keypair + known_hosts staged for Dokploy registrationSecrets to register in Dokploy (m's hands)
PALIADIN_REMOTE_HOST100.99.98.203PALIADIN_REMOTE_PORT22022PALIADIN_REMOTE_USERmPALIADIN_SSH_PRIVATE_KEYcat ~/.paliad-staging/paliad-prod-key(multi-line)PALIADIN_KNOWN_HOSTScat ~/.paliad-staging/known_hosts(one line)Phase A.5 (PENDING m's hands)
Validate
network_mode: host+ traefik routing on prod paliad.de:docker-compose.yml: addnetwork_mode: hosttoweb, removeexpose: ["8080"]curl --connect-timeout 5 -sSI https://paliad.de/— expect 200 (or login redirect), NOT 502git revert HEAD && git pushto roll back; revisit decision 1 in a follow-up issueThis step touches prod paliad.de — coder did NOT execute it without your hands.
Phase B unblocked from a code perspective
But should not merge until A.5 confirms host-mode is OK. Code work: Dockerfile +openssh-client; compose host-mode + 5 env vars; Go interface split (
Paliadininterface, renameLocalPaliadinService, newRemotePaliadinServiceinpaliadin_remote.go);cmd/server/main.goenv-var wiring;friendlyErrorMessagemriver_unreachable case; i18n keys.Two remaining open questions
ANTHROPIC_API_KEYenv var reservation in compose comments — keep for production-v1 or strip?Standing by for next instruction.
Phase B code merged into main as
1d7c7d7, bundling 7 commits frommai/noether/inventor-paliadin:befa41c— design doc (docs/design-paliadin-tailscale-ssh-2026-05-07.md)0248411—scripts/paliadin-shim(mRiver-side restricted shim)f952fb8— design amend: port 22022 bypass + Phase A.0 resultsf62bf9f— Dockerfile +openssh-client56a3dc9— refactor: extractPaliadininterface;PaliadinService→LocalPaliadinService0c8a2f1—RemotePaliadinService+DisabledPaliadinService+main.goenv-var switch (PALIADIN_REMOTE_HOST→ remote /tmuxon PATH → local / else → disabled)68c56ea— 14 unit tests viacallShimHook(no real SSH required)e4110cf— frontendfriendlyErrorMessagefor remote-Paliadin error codes (DE+EN)Production behavior unchanged. Without
PALIADIN_REMOTE_HOSTin env, paliad never invokes ssh — local-tmux PoC path is byte-identical (tests pass).Phase A.5 still pending m's hands —
da971a7(docker-composenetwork_mode: host+ 5 new env vars) is held onmai/noether/inventor-paliadinand explicitly markedDO NOT MERGE before Phase A.5. The compose flip's commit message has the A.5 procedure (curl test + revert path on M1 502).Three open items for m before this issue closes:
docker-compose.ymlhost-mode on a temp branch (or cherry-pickda971a7), redeploy, curlpaliad.de, gate the merge on 200 vs 502.PALIADIN_SSH_PRIVATE_KEY+PALIADIN_KNOWN_HOSTSas Dokploy secrets (values staged at~/.paliad-staging/on mRiver per issuecomment-6886).ANTHROPIC_API_KEYcomment line from compose.Phase A.5 + A.7 done — Paliadin chat works end-to-end from paliad.de prod.
m's "I still don't have a connection" was the symptom of two issues stacked on top of the original A.5 attempt that was reverted (
a80652a→82faa3don 2026-05-08 00:38).Root causes
Decision 1 (
network_mode: host) was actually wrong — not because traefik 502s (the M2 case I had designed for), but because Dokploy auto-injectsnetworks: [dokploy-network, default]on the primary service for traefik routing. Compose then refuses:service web declares mutually exclusive network_mode and networks: invalid compose project. That's the reverted-merge's failure mode, recorded in/etc/dokploy/logs/.../...:00:38:05.log.The host-mode premise was unnecessary anyway. Empirical test (commit log):
Plain alpine container on Dokploy's default bridge SSHs to mRiver fine. Docker source NAT masquerades the bridge IP onto mLake's tailscale0 (100.99.98.201), which matches the
from="100.99.98.201"clause on mRiver's authorized_keys. The kernel routes tailnet traffic for free; nonetwork_mode: host, no Tailscale-in-container needed.Multi-line PEM env vars don't survive Dokploy's
.envmechanism — got truncated to the BEGIN line (36 bytes) inside the container.ssh -i …failed withLoad key: error in libcrypto. Fixed by base64-encoding the secret and decoding inbuildPaliadinRemoteConfig.Commits to main today
a0d1e77— Phase A.5 (correct version): dropsnetwork_mode: host, adds 5 PALIADIN_* env entries to compose, includes the rationale + the empirical alpine-on-bridge proof in the commit body4c47819— base64-decodePALIADIN_SSH_PRIVATE_KEY; accepts both raw PEM (local-dev) and base64 (Dokploy)Dokploy compose
Zx147ycurfYagKRl_Zzyo(paliad) updated via API:PALIADIN_SSH_PRIVATE_KEYnow base64-encoded (560 chars, single line).End-to-end verification (inside the live paliad-prod container, 11:33)
paliad startup log confirms:
paliadin: remote mode → ssh m@100.99.98.203:22022. Claude pane reset + paliad container restarted clean so m's first /paliadin invocation gets the real system prompt via Go's lazyensureBootstrappedpath.Design doc follow-up
docs/design-paliadin-tailscale-ssh-2026-05-07.md§4–§4.5 / §7 are now empirically wrong — host mode was never needed. A small amendment is in scope, but not urgent (the production code works; the design rationale lives in the commit messages ofa0d1e77and4c47819).Status: t-paliad-151 working end-to-end. Standing by.
Phase A.5 + A.7 complete — Paliadin chat works end-to-end from paliad.de prod via SSH to mRiver.
Final commit chain on main:
a0d1e77— Phase A.5: compose env-var passthrough (5 PALIADIN_* entries; no host-mode flip needed)db3514c— Merge of the above4c47819— base64-decode SSH key (Dokploy.envtruncates multi-line values to first line)319221f— Merge of the aboveTwo empirical findings that override the original design
(1)
network_mode: hostis incompatible with this Dokploy app's compose lifecycle. Dokploy auto-injectsnetworks: [dokploy-network, default]on the primary service for traefik routing, which is mutually exclusive withnetwork_mode: host. First attempt at host mode (a80652a) failed compose validation; reverted as82faa3d.(2) host mode wasn't needed anyway. Verified by running a plain alpine container on Dokploy's default bridge:
Docker's outbound NAT masquerades the container's bridge IP onto mLake's host IPs, including
tailscale0(100.99.98.201). Linux routing on mLake sends100.99.98.0/24totailscale0. mRiver's sshd sees the connection coming from100.99.98.201, matching thefrom="100.99.98.201"clause on the paliad-prodauthorized_keysentry. The kernel does the masquerade for free — no Tailscale-in-container, no sidecar, no host networking.Design doc follow-up needed
docs/design-paliadin-tailscale-ssh-2026-05-07.md§4 (host-mode shape) is empirically wrong; §7 Phase A.5 needs an "M3: kernel does the masquerade for you" entry, and decision 1 in §3 should be amended. Filed as a TODO in the A.5 commit message — worth a small design-doc-amend follow-up before this thread closes.Done
t-paliad-155 merged into main as
5893c45. Bundle:97a4124— real Claude SKILL.md + per-user tmux session keying (paliad-paliadin-<user_id_short>)9579032— re-author skill via/write-a-skillconventions (96-line SKILL.md + 134-linereferences/sql-recipes.md)e75a71f— cwd fix: shim spawns claude in/home/m/dev/paliad(configurable viaPALIADIN_REMOTE_CWD) so project-scoped MCPs (Supabase) load. Solves m's 'no DB access' symptom from earlier dogfood.3e1f4ee—PALIADIN_TIMEOUT_Sdefault 60→120s for cold-start safety; SKILL.md bans psql/curl fallbacks (Claude must write 'DB unreachable' rather than nix-shelling postgres on a 1m20s detour). Solves m's 'loses connection before response came in' from earlier dogfood.Lockstep update on mRiver:
~/.local/bin/paliadin-shimrefreshed (new verb signatures:health <session>,run-turn <session> <uuid> <msg-base64>,reset <session>; bootstrap verb removed).~/.claude/skills/paliadin/refreshed viascripts/install-paliadin-skill. Both done before paliad container redeploys, so the new Go side talks to the new shim from the first post-deploy turn.Service-side (
paliadin_remote.go,paliadin.go,main.go):paliadinSystemPromptkeystroke-bootstrap path deleted. Per-user session keying derived fromreq.UserID.paliadin_prompt.goremoved (skill is now source of truth). 14 unit tests viacallShimHookupdated for the new shape.Known limitation flagged for next task (t-paliad-156, queued): even with the skill loaded and the right MCP, Claude queries via service role — sees ALL data, RLS bypassed. Skill enforces
paliad.can_see_projectpredicate as a stopgap, but it's discipline, not enforcement. m's call (2026-05-08 13:29): proper fix is per-turn JWT minted by paliad withsub=<user_id>, passed through SSH/shim/file to Claude, used asAuthorization: Beareragainst PostgREST. Filed as separate task; ships after this lands and is dogfooded.