Monorepo for Aesthetic.Computer aesthetic.computer
at main 51 lines 1.9 kB view raw
1#!/usr/bin/env fish 2# help tunnel — keep an SSH reverse tunnel to help.aesthetic.computer 3# 4# Run on your macbook to expose NanoClaw's HTTP Help channel (:3004) 5# on the help droplet as localhost:3005. 6# 7# Caddy on the droplet proxies help.aesthetic.computer → :3004 (proxy server) → :3005 (this tunnel) 8# 9# Usage: 10# fish tunnel.fish # Start tunnel (foreground) 11# fish tunnel.fish --background # Start tunnel in background with autossh 12 13set SCRIPT_DIR (dirname (status --current-filename)) 14set VAULT_DIR "$SCRIPT_DIR/../aesthetic-computer-vault" 15set SSH_KEY "$VAULT_DIR/home/.ssh/id_rsa" 16set HELP_HOST "help.aesthetic.computer" 17set LOCAL_PORT 3004 # NanoClaw HTTP Help port on macbook 18set REMOTE_PORT 3005 # Exposed on droplet via tunnel 19 20if not test -f $SSH_KEY 21 echo "SSH key not found: $SSH_KEY" 22 echo "Using default SSH key" 23 set SSH_KEY "" 24end 25 26set SSH_OPTS -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes 27 28if contains -- --background $argv 29 echo "Starting tunnel in background (autossh)..." 30 if command -q autossh 31 set -x AUTOSSH_POLL 30 32 if test -n "$SSH_KEY" 33 autossh -M 0 -f -N -R $REMOTE_PORT:localhost:$LOCAL_PORT $SSH_OPTS -i $SSH_KEY root@$HELP_HOST 34 else 35 autossh -M 0 -f -N -R $REMOTE_PORT:localhost:$LOCAL_PORT $SSH_OPTS root@$HELP_HOST 36 end 37 echo "Tunnel running. Check: ssh root@$HELP_HOST curl -s localhost:$REMOTE_PORT/health" 38 else 39 echo "autossh not found. Install: brew install autossh" 40 exit 1 41 end 42else 43 echo "Starting SSH tunnel (Ctrl+C to stop)..." 44 echo " macbook :$LOCAL_PORT → droplet :$REMOTE_PORT" 45 echo "" 46 if test -n "$SSH_KEY" 47 ssh -N -R $REMOTE_PORT:localhost:$LOCAL_PORT $SSH_OPTS -i $SSH_KEY root@$HELP_HOST 48 else 49 ssh -N -R $REMOTE_PORT:localhost:$LOCAL_PORT $SSH_OPTS root@$HELP_HOST 50 end 51end