How to Install Headscale on Arch Linux
Headscale is a self-hosted open-source implementation of the Tailscale network. It allows you to create a secure, peer-to-peer VPN in order to connect your devices from any location.
In this tutorial, we are going to show how to install Headscale on Arch Linux.
Prerequisites
Before you start, ensure that:
- You have a server running the latest version of Arch Linux.
- You have root access to the server.
- You have an SSH client installed on your local machine.
Step 1: Install Required Dependencies
First, we need to install the required dependencies on the Arch Linux server.
Open a terminal window and run the following command:
sudo pacman -S git go
This will install Git and Go on the server.
Step 2: Clone Headscale
Next, we need to clone the Headscale repository from GitHub.
Run the following command to clone the repository:
git clone https://github.com/juanfont/headscale.git
This will clone the Headscale repository in the current directory.
Step 3: Build Headscale
After cloning the repository, we need to build the Headscale binary.
Navigate to the Headscale directory, which contains the cloned repository, and run the following command:
cd headscale
go build -o headscale ./cmd/headscale/
This will build the Headscale binary.
Step 4: Move Headscale to /usr/local/bin
Next, we need to move the Headscale binary to the /usr/local/bin directory, so that it can be accessed from anywhere on the server.
Run the following command to move the binary:
sudo mv headscale /usr/local/bin/
Step 5: Create the Headscale Configuration File
Now, we need to create the Headscale configuration file.
Run the following command to create the configuration file:
sudo nano /etc/headscale.conf
This will open the Nano text editor.
In the editor, paste the following configuration:
[headscale]
privateKey = ""
database = "sqlite3:///var/lib/headscale/headscale.db"
listenOn = "0.0.0.0:8080"
hostname = ""
letsencrypt = false
tailscaleCompatKey = ""
Replace the privateKey and tailscaleCompatKey fields with the keys you want to use.
Step 6: Create the Headscale Systemd Service
To run Headscale as a service, we need to create a systemd unit file.
Create a new unit file by running the following command:
sudo nano /etc/systemd/system/headscale.service
Paste the following configuration in the unit file:
[Unit]
Description=Headscale service
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/usr/local/bin/
ExecStart=/usr/local/bin/headscale -config /etc/headscale.conf -logtostderr=true
[Install]
WantedBy=multi-user.target
Save and close the file.
Step 7: Start and Enable Headscale
Now, we can start and enable the Headscale service.
To start the service, run the following command:
sudo systemctl start headscale
To enable the service, so it starts automatically when the server boots up, run the following command:
sudo systemctl enable headscale
Conclusion
You have successfully installed Headscale on your Arch Linux server. You can now configure your network and start using Headscale to connect your devices securely from any location.