summaryrefslogtreecommitdiff
path: root/client.sh
diff options
context:
space:
mode:
Diffstat (limited to 'client.sh')
-rwxr-xr-xclient.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/client.sh b/client.sh
new file mode 100755
index 0000000..2118a73
--- /dev/null
+++ b/client.sh
@@ -0,0 +1,44 @@
1#!/bin/bash
2# Install tailscale and register with a headscale server
3# Copy to a VM and run: sudo ./client.sh <server_ip> <auth_key>
4# Example: sudo ./client.sh 37.27.166.243 hskey-auth-xxxx
5# macOS CLI: echo 'alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"' >> ~/.zshrc
6set -e
7
8die() { echo "Error: $1" >&2; exit 1; }
9info() { echo " $1"; }
10
11[[ $EUID -eq 0 ]] || die "Must run as root"
12
13SERVER_IP="${1:?Usage: $0 <server_ip> <auth_key>}"
14AUTH_KEY="${2:?Usage: $0 <server_ip> <auth_key>}"
15LOGIN_SERVER="http://${SERVER_IP}:8080"
16
17echo "=== Installing Tailscale Client ==="
18echo "Server: $LOGIN_SERVER"
19echo ""
20
21# 1. Install tailscale
22if command -v tailscale &>/dev/null; then
23 info "Tailscale already installed: $(tailscale version | head -1)"
24else
25 info "Installing tailscale..."
26 dnf install -y tailscale
27fi
28
29# 2. Start tailscaled
30info "Starting tailscaled..."
31systemctl enable --now tailscaled
32
33# 3. Register with headscale
34info "Registering with headscale at $LOGIN_SERVER..."
35tailscale up --login-server "$LOGIN_SERVER" --authkey "$AUTH_KEY"
36
37# 4. Show status
38echo ""
39echo "=== Connected ==="
40tailscale status
41echo ""
42echo "To disconnect: tailscale down"
43echo "To switch server: tailscale down && tailscale up --login-server http://<new_ip>:8080 --authkey <key> --force-reauth"
44echo "To remove: tailscale down && systemctl disable --now tailscaled && dnf remove -y tailscale"