Skip to content

Instantly share code, notes, and snippets.

@adrienthebo
Forked from legowerewolf/readme.md
Created February 22, 2023 17:53
Show Gist options
  • Save adrienthebo/1cb6ff629943724d33d7d89e5702cc0c to your computer and use it in GitHub Desktop.
Save adrienthebo/1cb6ff629943724d33d7d89e5702cc0c to your computer and use it in GitHub Desktop.
Tailscale on Steam Deck

Tailscale on the Steam Deck

This process is derived from the official guide, but lightly tweaked to make the process smoother and produce an installation that comes up automatically on boot (no need to enter desktop mode) and survives system updates.

Installing Tailscale

⚠️ This process will probably fail if you are accessing the terminal over Tailscale SSH, as it seems to be locked in a chroot jail. You should start and connect through the standard SSH server instead. Suggestions for how to fix this are welcomed.

  1. Download the attached tailscale.sh and tailscaled.service files to your Deck.
  2. Copy the tailscaled.service file to /etc/systemd/system/.
  3. Run sudo bash tailscale.sh to install Tailscale (or update the existing installation).
  4. Run sudo tailscale up --qr --operator=deck --ssh to have Tailscale generate a login QR code. Scan the code with your phone and authenticate with Tailscale to bring your Deck onto your network.

How it works

It uses the same system extension method as the official guide, but we put the tailscaled.service file directly in /etc/systemd/system/ because it's actually safe to put things there. Changes in /etc/ are preserved in /var/lib/overlays/etc/upper/ via an overlayfs, meaning that they survive updates.

#!/usr/bin/env bash
# make system configuration vars available
source /etc/os-release
# set invocation settings for this script:
# -e: Exit immediately if a command exits with a non-zero status.
# -u: Treat unset variables as an error when substituting.
# -o pipefail: the return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status
set -eu -o pipefail
# save the current directory silently
pushd . > /dev/null
# make a temporary directory, save the name, and move into it
dir="$(mktemp -d)"
cd "${dir}"
echo -n "Installing Tailscale: Getting version..."
# get info for the latest version of Tailscale
tarball="$(curl -s 'https://pkgs.tailscale.com/stable/?mode=json' | jq -r .Tarballs.amd64)"
version="$(echo ${tarball} | cut -d_ -f2)"
echo -n "got ${version}. Downloading..."
# download the Tailscale package itself
curl -s "https://pkgs.tailscale.com/stable/${tarball}" -o tailscale.tgz
echo -n "done. Installing..."
# extract the tailscale binaries
tar xzf tailscale.tgz
tar_dir="$(echo ${tarball} | cut -d. -f1-3)"
test -d $tar_dir
# create our target directory structure
mkdir -p tailscale/usr/{bin,sbin,lib/{systemd/system,extension-release.d}}
# pull things into the right place in the target dir structure
cp -rf $tar_dir/tailscale tailscale/usr/bin/tailscale
cp -rf $tar_dir/tailscaled tailscale/usr/sbin/tailscaled
# write a systemd extension-release file
echo -e "SYSEXT_LEVEL=1.0\nID=steamos\nVERSION_ID=${VERSION_ID}" >> tailscale/usr/lib/extension-release.d/extension-release.tailscale
# create the system extension folder if it doesn't already exist, remove the old version of our tailscale extension, and install our new one
mkdir -p /var/lib/extensions
rm -rf /var/lib/extensions/tailscale
cp -rf tailscale /var/lib/extensions/
# return to our original directory (silently) and clean up
popd > /dev/null
rm -rf "${dir}"
systemd-sysext refresh > /dev/null 2>&1
systemctl daemon-reload > /dev/null
systemctl enable systemd-sysext --now
systemctl enable tailscaled --now
echo "done."
echo "If updating, reboot or run the following to finish the process: sudo systemctl restart tailscaled"
[Unit]
Description=Tailscale node agent
Documentation=https://tailscale.com/kb/
Wants=network-pre.target
After=network-pre.target NetworkManager.service systemd-resolved.service
[Service]
ExtensionDirectories=/var/lib/extensions/tailscale
ExecStartPre=/usr/sbin/tailscaled --cleanup
ExecStart=/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock
ExecStopPost=/usr/sbin/tailscaled --cleanup
Restart=on-failure
RuntimeDirectory=tailscale
RuntimeDirectoryMode=0755
StateDirectory=tailscale
StateDirectoryMode=0700
CacheDirectory=tailscale
CacheDirectoryMode=0750
Type=notify
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment