#!/bin/bash # Install tailscale and register with a headscale server # Copy to a VM and run: sudo ./client.sh # Example: sudo ./client.sh 37.27.166.243 hskey-auth-xxxx # macOS CLI: echo 'alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"' >> ~/.zshrc set -e die() { echo "Error: $1" >&2; exit 1; } info() { echo " $1"; } [[ $EUID -eq 0 ]] || die "Must run as root" SERVER_IP="${1:?Usage: $0 }" AUTH_KEY="${2:?Usage: $0 }" LOGIN_SERVER="http://${SERVER_IP}:8080" echo "=== Installing Tailscale Client ===" echo "Server: $LOGIN_SERVER" echo "" # 1. Install tailscale if command -v tailscale &>/dev/null; then info "Tailscale already installed: $(tailscale version | head -1)" else info "Installing tailscale..." dnf install -y tailscale fi # 2. Start tailscaled info "Starting tailscaled..." systemctl enable --now tailscaled # 3. Register with headscale info "Registering with headscale at $LOGIN_SERVER..." tailscale up --login-server "$LOGIN_SERVER" --authkey "$AUTH_KEY" # 4. Show status echo "" echo "=== Connected ===" tailscale status echo "" echo "To disconnect: tailscale down" echo "To switch server: tailscale down && tailscale up --login-server http://:8080 --authkey --force-reauth" echo "To remove: tailscale down && systemctl disable --now tailscaled && dnf remove -y tailscale"