Skip to content

VPS Deployment

guan4tou2 edited this page Jul 31, 2026 · 1 revision

VPS Deployment

hooks/vps-deploy.sh installs the RedLog shell hook on a remote box and opens a reverse SSH tunnel so every command run there lands in the local chain in real time. Same code path as the local hook — it just POSTs to 127.0.0.1:6660 from the VPS side, which routes back to the operator's machine through -R.

Prerequisites

  • RedLog running locally with an open project (so ~/.redlog/api-token + ~/.redlog/api-port exist).
  • SSH access to the VPS (key-based auth recommended so the tunnel doesn't break on the reverse leg).
  • bash, curl, and python3 on the VPS (needed by shell-preexec-hook.sh).

Three subcommands

install

One-time copy. Scp's the hook to ~/.redlog-hook.sh, writes ~/.redlog/api-token (mode 600) and ~/.redlog/api-port=6660, and appends source ~/.redlog-hook.sh to the operator's .bashrc and .zshrc if not already there.

./hooks/vps-deploy.sh install operator@vps.example.com

tunnel

Foreground ssh -R 6660:127.0.0.1:6660 operator@vps.example.com. Every command you run on the VPS during this session hits the local RedLog chain through the tunnel. Server-alive interval 30s / count 3 keeps the tunnel from silently dropping on flaky links.

./hooks/vps-deploy.sh tunnel operator@vps.example.com

Exit the ssh session (Ctrl-D) to close the tunnel.

uninstall

Removes ~/.redlog-hook.sh, ~/.redlog/api-token, ~/.redlog/api-port, and strips the source line out of .bashrc / .zshrc.

./hooks/vps-deploy.sh uninstall operator@vps.example.com

What lands in the chain

Same events as the local hook — shell.command_start and shell.command_end with source: 'builtin-terminal' and terminalId reflecting the VPS identity, plus:

  • data.host — hostname of the VPS (from uname -n)
  • data.user — remote user
  • data.cwd — remote cwd at command_end
  • data.exit_code, data.duration_sec as usual

The interactive-ssh pivot event already fired locally when you ran the ssh line, so the timeline shows the transition into and out of the VPS session.

Not (yet) covered

  • Windows / PowerShell VPS: only bash/zsh hooks are packaged in the install step.
  • Multi-hop pivot (VPS → target through another VPS): each hop needs its own install + reverse tunnel; the local API only listens on 6660 so both legs bind to the same port and the second hop's tunnel wins.
  • Ephemeral VPS on-boot install: bake the hook into your cloud-init / user-data if the VPS is short-lived.

See also

  • hooks/vps-deploy.sh — script source.
  • SSH & Session Replay — the non-hook approach (session replay from local .cast).
  • Hook Privacy — how the exclusion list interacts with remote-tunnel events (recording gate still applies).

Clone this wiki locally