Running headscale on Linux¶
Outdated and advanced
This documentation is considered the "legacy"/advanced/manual version of the documentation, you most likely do not want to use this documentation and rather look at the distro specific documentation.
Goal¶
This documentation has the goal of showing a user how-to set up and run headscale
on Linux. In additional to the "get up and running section", there is an optional systemd section describing how to make headscale
run properly in a server environment.
Configure and run headscale
¶
-
Download the latest
headscale
binary from GitHub's release page: -
Make
headscale
executable: -
Prepare a directory to hold
headscale
configuration and the SQLite database:# Directory for configuration mkdir -p /etc/headscale # Directory for Database, and other variable data (like certificates) mkdir -p /var/lib/headscale # or if you create a headscale user: useradd \ --create-home \ --home-dir /var/lib/headscale/ \ --system \ --user-group \ --shell /usr/sbin/nologin \ headscale
-
Create a
headscale
configuration:(Strongly Recommended) Download a copy of the example configuration from the headscale repository.
-
Start the headscale server:
This command will start
headscale
in the current terminal session.
To continue the tutorial, open a new terminal and let it run in the background. Alternatively use terminal emulators like tmux or screen.
To run
headscale
in the background, please follow the steps in the systemd section before continuing. -
Verify
headscale
is running: Verifyheadscale
is available: -
Create a user (tailnet):
Register a machine (normal login)¶
On a client machine, execute the tailscale
login command:
Register the machine:
Register machine using a pre authenticated key¶
Generate a key using the command line:
This will return a pre-authenticated key that can be used to connect a node to headscale
during the tailscale
command:
Running headscale
in the background with systemd¶
This section demonstrates how to run headscale
as a service in the background with systemd. This should work on most modern Linux distributions.
-
Copy headscale's systemd service file to
/etc/systemd/system/headscale.service
and adjust it to suit your local setup. The following parameters likely need to be modified:ExecStart
,WorkingDirectory
,ReadWritePaths
.Note that when running as the headscale user ensure that, either you add your current user to the headscale group:
or run all headscale commands as the headscale user:
-
In
/etc/headscale/config.yaml
, override the defaultheadscale
unix socket with path that is writable by theheadscale
user or group: -
Reload systemd to load the new configuration file:
-
Enable and start the new
headscale
service: -
Verify the headscale service:
Verify
headscale
is available:
headscale
will now run in the background and start at boot.