headscale/docs/running-headscale-linux.md
nblock e43d6a0361
Move flags after the command (#2100)
The built-in help also shows flags to given after the command. Align
documentation examples accordingly.
2024-09-04 12:38:38 +00:00

2.3 KiB

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

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.

You should not delete the database (/var/lib/headscale/db.sqlite) and the configuration (/etc/headscale/config.yaml).

Installation

  1. Download the latest Headscale package for your platform (.deb for Ubuntu and Debian).

    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"
    wget --output-document=headscale.deb \
      "https://github.com/juanfont/headscale/releases/download/v${HEADSCALE_VERSION}/headscale_${HEADSCALE_VERSION}_linux_${HEADSCALE_ARCH}.deb"
    
  2. Install Headscale:

    sudo apt install ./headscale.deb
    
  3. Enable Headscale service, this will start Headscale at boot:

    sudo systemctl enable headscale
    
  4. Configure Headscale by editing the configuration file:

    nano /etc/headscale/config.yaml
    
  5. Start Headscale:

    sudo systemctl start headscale
    
  6. Check that Headscale is running as intended:

    systemctl status headscale
    

Using Headscale

Create a user

headscale users create myfirstuser

Register a machine (normal login)

On a client machine, run the tailscale login command:

tailscale up --login-server <YOUR_HEADSCALE_URL>

Register the machine:

headscale nodes register --user myfirstuser --key <YOUR_MACHINE_KEY>

Register machine using a pre authenticated key

Generate a key using the command line:

headscale preauthkeys create --user myfirstuser --reusable --expiration 24h

This will return a pre-authenticated key that is used to connect a node to headscale during the tailscale command:

tailscale up --login-server <YOUR_HEADSCALE_URL> --authkey <YOUR_AUTH_KEY>