Skip to content

Instantly share code, notes, and snippets.

@maple3142
Last active June 12, 2024 09:43
Show Gist options
  • Save maple3142/53a1a21271a281eb111e9f0739ccb956 to your computer and use it in GitHub Desktop.
Save maple3142/53a1a21271a281eb111e9f0739ccb956 to your computer and use it in GitHub Desktop.
Rootless Tailscale

Running tailscaled

Download static tailscaled binary here

TAILSCALED_SOCKET="/tmp2/$USER/tailscaled.sock"
TAILSCALED_STATE="tailscaled.state"
./tailscaled --tun=userspace-networking --state="$TAILSCALED_STATE" --socket "$TAILSCALED_SOCKET"

then use it like this:

./tailscale --socket "$TAILSCALED_SOCKET" login
./tailscale --socket "$TAILSCALED_SOCKET" status
./tailscale --socket "$TAILSCALED_SOCKET" ...  # whatever

Access tailnet services using proxychains (optional)

Official Docs: Userspace networking mode

Add --socks5-server=localhost:21055 --outbound-http-proxy-listen=localhost:21055 to the ./tailscaled start command.

Create proxychains.conf:

strict_chain
proxy_dns
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
socks5 127.0.0.1 21055

Then use it like this:

proxychains -f proxychains.conf -q ssh user@server

The ssh command can be replaced with any other command you want to run. It is also possible to proxy your shell like this:

proxychains -f proxychains.conf -q $SHELL

Running derper (optional)

Official Docs: DERP Servers

Install derper: go install tailscale.com/cmd/derper@main

generate a self-signed cert:

DOMAIN="my-server.example.com"  # can be an ip if you want
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout "$DOMAIN.key" -out "$DOMAIN.crt" -subj "/CN=$DOMAIN" -addext "subjectAltName=DNS:$DOMAIN"

run it:

DERPPort=28443
STUNPort=23478
~/go/bin/derper --hostname="$DOMAIN" -http-port=-1 -a=:$DERPPort -stun-port=$STUNPort -certmode manual -certdir $PWD -c derp_config.json

then add this to tailscale's ACL:

	"derpMap": {
		"Regions": {
			"900": {
				"RegionID":   900,
				"RegionCode": "ANY_THING_YOU_WANT",
				"Nodes": [
					{
						"Name":             "ANY_THING_YOU_WANT",
						"RegionID":         900,
						"DERPPort":         $DERPPort,
						"STUNPort":         $STUNPort,
						"HostName":         "$DOMAIN",
						"InsecureForTests": true,
					},
				],
			},
		},
	},
@SuperKenVery
Copy link

Thanks man, works great in a server where root is discouraged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment