diff --git a/content/docs/networking/remote-access.mdx b/content/docs/networking/remote-access.mdx index e91f459..acdf97d 100644 --- a/content/docs/networking/remote-access.mdx +++ b/content/docs/networking/remote-access.mdx @@ -52,7 +52,7 @@ Tailscale is not pre-installed on the device. However, Tailscale has added out-o 2. **On your local computer** (not on the JetKVM device), run the following command and follow the instructions: ```bash -curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- +curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- -i ``` ### Additional Tailscale Arguments @@ -60,11 +60,11 @@ curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- If you use a self-hosted Tailscale coordination server such as [Headscale](https://github.com/juanfont/headscale), you can pass additional arguments to the `tailscale up` command by appending them after `--` following the JetKVM IP address. Any arguments after the second `--` are forwarded directly to [`tailscale up`](https://tailscale.com/docs/reference/tailscale-cli/up). ```bash -curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- -- --login-server=https://headscale.example.com +curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- -i -- --login-server=https://headscale.example.com ``` You can also combine multiple `tailscale up` flags: ```bash -curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- -- --login-server=https://headscale.example.com --advertise-tags=tag:kvm +curl -fsSL https://jetkvm.com/install-tailscale.sh | sh -s -- -i -- --login-server=https://headscale.example.com --advertise-tags=tag:kvm ``` diff --git a/content/scripts/install-tailscale.sh b/content/scripts/install-tailscale.sh index 76e3953..501b3ea 100755 --- a/content/scripts/install-tailscale.sh +++ b/content/scripts/install-tailscale.sh @@ -14,6 +14,7 @@ main() { AUTO_YES=false CLEAN_INSTALL=false TAILSCALE_UP_ARGS="" + SSH_KEY="$HOME/.ssh/id_rsa" # Parse command line arguments while [ $# -gt 0 ]; do @@ -22,6 +23,10 @@ main() { REQUESTED_VERSION="$2" shift 2 ;; + -i | --identity) + SSH_KEY="$2" + shift 2 + ;; -y | --yes) AUTO_YES=true shift @@ -45,10 +50,11 @@ main() { if [ -z "$JETKVM_IP" ]; then echo "ERROR: JetKVM IP address is required" echo "" - echo "Usage: $0 [-v|--version ] [-y|--yes] [-c|--clean] [-- ...]" + echo "Usage: $0 [-v|--version ] [-i|--identity ] [-y|--yes] [-c|--clean] [-- ...]" echo "" echo "Options:" echo " -v, --version Specify Tailscale version (defaults to current stable release)" + echo " -i, --identity Path to the SSH private key for the JetKVM (defaults to ~/.ssh/id_rsa)" echo " -y, --yes Automatically answer yes to confirmation prompt" echo " -c, --clean Delete any existing tailscale data (will cause a new machine to be created)" echo "" @@ -72,6 +78,14 @@ main() { export TAILSCALE_VERSION="${REQUESTED_VERSION:-$TAILSCALE_STABLE}" + if [ ! -f "$SSH_KEY" ]; then + echo "ERROR: SSH key not found at: $SSH_KEY" + echo " Provide a valid key path with -i/--identity, or place your key at ~/.ssh/id_rsa" + exit 1 + fi + + SSH_OPTS="-i $SSH_KEY -o IdentitiesOnly=yes" + # Confirmation prompt (unless auto-yes is enabled) if [ "$AUTO_YES" = false ]; then echo "──────────────────────────────────────────────────────────" @@ -128,7 +142,7 @@ main() { echo " Checking SSH access (Developer Mode)..." # First, test SSH connectivity without BatchMode to get proper error messages - SSH_TEST_OUTPUT=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + SSH_TEST_OUTPUT=$(ssh $SSH_OPTS -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes -o PasswordAuthentication=no \ root@"$JETKVM_IP" 'echo "SSH OK"' 2>&1) || SSH_EXIT_CODE=$? @@ -181,10 +195,10 @@ main() { echo " Package verification successful" echo "[5/7] Transferring Tailscale package to JetKVM..." - ssh root@"${JETKVM_IP}" "cat > /userdata/tailscale.tgz" <"$TMP_FILE" + ssh $SSH_OPTS root@"${JETKVM_IP}" "cat > /userdata/tailscale.tgz" <"$TMP_FILE" echo "[6/7] Installing and configuring Tailscale on JetKVM..." - ssh -o ServerAliveInterval=1 -o ServerAliveCountMax=1 \ + ssh $SSH_OPTS -o ServerAliveInterval=1 -o ServerAliveCountMax=1 \ root@"$JETKVM_IP" \ "export TAILSCALE_VERSION=$TAILSCALE_VERSION CLEAN_INSTALL=$CLEAN_INSTALL; ash -s" 2>/dev/null <<'EOF' || true set -e @@ -223,7 +237,7 @@ EOF i=1 while [ "$i" -le 120 ]; do echo " Checking device status... ($i/120s)" - if ssh -q -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + if ssh $SSH_OPTS -q -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ root@"$JETKVM_IP" 'tailscale version' >/dev/null 2>&1; then echo " JetKVM is back online with Tailscale installed!" break @@ -240,7 +254,7 @@ EOF done echo "[7/7] Starting Tailscale service..." - ssh root@"$JETKVM_IP" "tailscale up $TAILSCALE_UP_ARGS" + ssh $SSH_OPTS root@"$JETKVM_IP" "tailscale up $TAILSCALE_UP_ARGS" echo "" echo "SUCCESS: Tailscale installation completed!" echo " Your JetKVM device is now ready to connect to your Tailscale network."