To set up the auth key, run:
# Create a directory for the auth key
sudo mkdir -p /etc/tailscale
# Store the auth key in a file with secure permissions
# Replace 'tskey-auth-abc123' with the actual auth key you generated.
echo "tskey-auth-abc123" | sudo tee /etc/tailscale/authkey
sudo chmod 600 /etc/tailscale/authkey
# Create the systemd service file
sudo tee /etc/systemd/system/tailscale-up.service <<EOF
[Unit]
Description=Tailscale Up
After=tailscaled.service network-online.target
Requires=tailscaled.service
Wants=network-online.target
[Service]
ExecStart=/usr/bin/tailscale up --authkey-file=/etc/tailscale/authkey --accept-routes=true --accept-dns=true
Restart=on-failure
RestartSec=5s
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the new service
sudo systemctl daemon-reload
sudo systemctl enable tailscale-up.service
sudo systemctl start tailscale-up.service