2023-04-19 15:04:43 +00:00
|
|
|
# Running headscale on Linux
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
- Ubuntu 20.04 or newer, Debian 11 or newer.
|
|
|
|
|
|
|
|
## Goal
|
|
|
|
|
|
|
|
Get Headscale up and running.
|
|
|
|
|
|
|
|
This includes running Headscale with SystemD.
|
|
|
|
|
|
|
|
## Migrating from manual install
|
2023-04-19 15:06:50 +00:00
|
|
|
|
2023-04-19 15:04:43 +00:00
|
|
|
If you are migrating from the old manual install, the best thing would be to remove
|
|
|
|
the files installed by following [the guide in reverse](./running-headscale-linux-manual.md).
|
|
|
|
|
2024-03-19 21:43:43 +00:00
|
|
|
You should _not_ delete the database (`/var/lib/headscale/db.sqlite`) and the
|
2023-04-19 15:04:43 +00:00
|
|
|
configuration (`/etc/headscale/config.yaml`).
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2024-05-06 18:06:30 +00:00
|
|
|
1. Download the [latest Headscale package](https://github.com/juanfont/headscale/releases/latest) for your platform (`.deb` for Ubuntu and Debian).
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
2024-05-06 18:06:30 +00:00
|
|
|
HEADSCALE_VERSION="" # See above URL for latest version, e.g. "X.Y.Z" (NOTE: do not add the "v" prefix!)
|
|
|
|
HEADSCALE_ARCH="" # Your system architecture, e.g. "amd64"
|
2024-03-22 18:55:20 +00:00
|
|
|
wget --output-document=headscale.deb \
|
2024-05-06 18:06:30 +00:00
|
|
|
"https://github.com/juanfont/headscale/releases/download/v${HEADSCALE_VERSION}/headscale_${HEADSCALE_VERSION}_linux_${HEADSCALE_ARCH}.deb"
|
2024-03-22 18:55:20 +00:00
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
1. Install Headscale:
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
2024-05-06 18:06:30 +00:00
|
|
|
sudo apt install ./headscale.deb
|
2024-03-22 18:55:20 +00:00
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
1. Enable Headscale service, this will start Headscale at boot:
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
|
|
|
sudo systemctl enable headscale
|
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
1. Configure Headscale by editing the configuration file:
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
|
|
|
nano /etc/headscale/config.yaml
|
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
1. Start Headscale:
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
|
|
|
sudo systemctl start headscale
|
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
1. Check that Headscale is running as intended:
|
2023-04-19 15:04:43 +00:00
|
|
|
|
2024-03-22 18:55:20 +00:00
|
|
|
```shell
|
|
|
|
systemctl status headscale
|
|
|
|
```
|
2023-04-19 15:04:43 +00:00
|
|
|
|
|
|
|
## Using Headscale
|
|
|
|
|
|
|
|
### Create a user
|
|
|
|
|
|
|
|
```shell
|
|
|
|
headscale users create myfirstuser
|
|
|
|
```
|
|
|
|
|
|
|
|
### Register a machine (normal login)
|
|
|
|
|
|
|
|
On a client machine, run the `tailscale` login command:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
tailscale up --login-server <YOUR_HEADSCALE_URL>
|
|
|
|
```
|
|
|
|
|
|
|
|
Register the machine:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
headscale --user myfirstuser nodes register --key <YOUR_MACHINE_KEY>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Register machine using a pre authenticated key
|
|
|
|
|
|
|
|
Generate a key using the command line:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
headscale --user myfirstuser preauthkeys create --reusable --expiration 24h
|
|
|
|
```
|
|
|
|
|
|
|
|
This will return a pre-authenticated key that is used to
|
|
|
|
connect a node to `headscale` during the `tailscale` command:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
tailscale up --login-server <YOUR_HEADSCALE_URL> --authkey <YOUR_AUTH_KEY>
|
|
|
|
```
|