Last active
February 16, 2026 22:39
-
-
Save ts-sz/755ae51d2e867e6c9afc110e400d066e to your computer and use it in GitHub Desktop.
XO One - bore SSH tunnel
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
| #!/bin/sh | |
| # bore-connect.sh - XO One SSH tunnel via bore | |
| # Usage: bore-connect.sh <LOCAL_PORT> | |
| # e.g. bore-connect.sh 22 | |
| # e.g. bore-connect.sh 8006 | |
| # e.g. BORE_PORT=443 bore-connect.sh | |
| set -e | |
| PORT="${BORE_PORT:-${1:-}}" | |
| if [ -z "$PORT" ]; then | |
| printf "[!] Port required.\n" | |
| printf " Usage: BORE_PORT=22 curl -sSL <url> | sh\n" | |
| printf " Or: %s <PORT>\n" "$0" | |
| exit 1 | |
| fi | |
| XO_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEIqOvIXLaoUH6hL15O2A5D4tSVL6F1VxLxjsu84X9a xo-one@openclaw" | |
| SESSION="bore-xo" | |
| # Check dependencies | |
| for cmd in curl tmux; do | |
| command -v $cmd >/dev/null 2>&1 || { echo "[!] $cmd required but not found."; exit 1; } | |
| done | |
| # Kill old session if exists | |
| tmux kill-session -t "$SESSION" 2>/dev/null || true | |
| # Write the worker script to /tmp | |
| cat > /tmp/bore-worker.sh << 'WORKER' | |
| #!/bin/sh | |
| XO_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEIqOvIXLaoUH6hL15O2A5D4tSVL6F1VxLxjsu84X9a xo-one@openclaw" | |
| cleanup() { | |
| printf "\n[*] Cleaning up...\n" | |
| grep -v "xo-one@openclaw" ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp 2>/dev/null || true | |
| mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys 2>/dev/null || true | |
| rm -f /tmp/bore /tmp/bore-worker.sh 2>/dev/null || true | |
| printf "[*] Key removed. Done.\n" | |
| exit 0 | |
| } | |
| trap cleanup INT TERM | |
| # Install SSH key | |
| mkdir -p ~/.ssh && chmod 700 ~/.ssh | |
| touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys | |
| grep -q "xo-one@openclaw" ~/.ssh/authorized_keys 2>/dev/null || echo "$XO_KEY" >> ~/.ssh/authorized_keys | |
| # Download bore if needed | |
| if [ ! -f /tmp/bore ]; then | |
| printf "[*] Downloading bore...\n" | |
| ARCH=$(uname -m) | |
| case "$ARCH" in x86_64) A="x86_64";; aarch64) A="aarch64";; *) printf "[!] Unsupported arch: %s\n" "$ARCH"; exit 1;; esac | |
| curl -sSL "https://github.com/ekzhang/bore/releases/download/v0.5.2/bore-v0.5.2-${A}-unknown-linux-musl.tar.gz" | tar xz -C /tmp 2>/dev/null || { printf "[!] Download failed\n"; exit 1; } | |
| chmod +x /tmp/bore | |
| fi | |
| # Start tunnel | |
| printf "\n" | |
| printf "=========================================\n" | |
| printf " bore tunnel - port %s\n" "$PORT" | |
| printf " Ctrl+C to close (auto-cleanup)\n" | |
| printf "=========================================\n\n" | |
| /tmp/bore local "$PORT" --to bore.pub | |
| cleanup | |
| WORKER | |
| chmod +x /tmp/bore-worker.sh | |
| # Launch in tmux | |
| tmux new-session -d -s "$SESSION" "PORT=$PORT sh /tmp/bore-worker.sh" | |
| sleep 3 | |
| # Display result | |
| printf "\n" | |
| printf "=========================================\n" | |
| printf " bore tunnel running in tmux '%s'\n" "$SESSION" | |
| printf " local port: %s\n" "$PORT" | |
| printf "\n" | |
| printf " View: tmux attach -t %s\n" "$SESSION" | |
| printf " Stop: tmux kill-session -t %s\n" "$SESSION" | |
| printf "=========================================\n\n" | |
| tmux capture-pane -t "$SESSION" -p 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment