Created
November 4, 2025 21:04
-
-
Save dz4k/d6a2383fa78dbf00e13f38dcc8ca9a2c to your computer and use it in GitHub Desktop.
Running tailscale as a user service
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
| # Add to .bashrc | |
| command -v tailscale >/dev/null && { | |
| alias tailscale='tailscale --socket=$XDG_RUNTIME_DIR/tailscale/tailscaled.sock' | |
| source <(tailscale completion bash) | |
| } |
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
| #!/usr/bin/env bash | |
| # Download tailscale and install into .local/bin | |
| # Requires tailscaled.service to already be placed in correct location | |
| tmp=$(mktemp -d) | |
| # TODO: auto download latest version | |
| curl https://pkgs.tailscale.com/stable/tailscale_1.90.6_amd64.tgz | tar xf -C "$tmp" | |
| tsdir=$(find . -name 'tailscale_*' -type d | head -n1) | |
| cp "$tsdir"/{tailscale,tailscaled} ~/.local/bin/ | |
| systemctl --user enable --now tailscaled.service |
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
| [Unit] | |
| Description=Tailscale node agent -- modified to run as user service | |
| Documentation=https://tailscale.com/kb/ | |
| After=network-online.target | |
| Wants=network-online.target | |
| [Service] | |
| # TODO: don't hardcode .local/bin, use $XDG_BIN_HOME | |
| # problem: that's not set on most systems, and systemd env var expansion | |
| # doesn't support default values | |
| ExecStart=%h/.local/bin/tailscaled --state=${STATE_DIRECTORY}/tailscaled.state --socket=${RUNTIME_DIRECTORY}/tailscaled.sock -tun=userspace-networking --port=41641 | |
| ExecStopPost=%h/.local/bin/tailscaled --cleanup | |
| Restart=on-failure | |
| RuntimeDirectory=tailscale | |
| RuntimeDirectoryMode=0755 | |
| StateDirectory=tailscale | |
| StateDirectoryMode=0700 | |
| CacheDirectory=tailscale | |
| CacheDirectoryMode=0750 | |
| Type=notify | |
| [Install] | |
| WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment