Building a Self-Hosted RustDesk Remote Desktop Server

Words 493
Views
Visitors

Timeline

Timeline

2025-03-14

init

This article introduces the complete process of building a self-hosted RustDesk remote desktop server based on Ubuntu and Docker in a local area network environment. It details Docker environment preparation, port settings, and docker-compose deployment, and summarizes the installation of the Windows client, configuration of ID/relay server IP and key, and the final connection method, providing users with a free, high-frame-rate, and high-resolution remote control alternative.

After using ToDesk for a few days without shutting down, I exhausted all my quota by mid-month and was no longer allowed to use it for free. I uninstalled it and switched to RustDesk, using self-host. It’s free, and the frame rate and resolution are much higher than ToDesk’s free version. Below is the setup record.

Basic Environment Setup

I use two Windows (Win10) machines and one Ubuntu (configuration as shown below). Using Ubuntu as the ID/relay server, one Windows connects to the other. Ubuntu needs Docker installed, and both Windows machines need RustDesk installed and configured.

Note: My three machines are on the same local area network.

Hardware Environment
Hardware Environment

Install Docker and docker-compose-plugin

Reference:

After installation, you can add the current user to the docker user group

1
2
3
4
5
6
7
# Add the docker user group, usually already exists, no need to execute
sudo groupadd docker
# Add the current user to the docker user group
sudo gpasswd -a $USER docker
# Update the user group
newgrp docker
docker version

docker-compose.yaml

Refer to the official documentation:

If ufw is enabled, these ports need to be opened:

1
2
3
4
sudo ufw status
sudo ufw allow 21114:21119/tcp
sudo ufw allow 8000/tcp
sudo ufw allow 21116/udp

Choose a directory to store ID/relay server data:

1
2
3
mkdir -p ~/rustdesk
cd ~/rustdesk
touch docker-compose.yaml

Below is the docker-compose.yaml file from the RustDesk official documentation above:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
services:
hbbs:
container_name: hbbs
image: rustdesk/rustdesk-server:latest
command: hbbs
volumes:
- ./data:/root
network_mode: "host"

depends_on:
- hbbr
restart: unless-stopped

hbbr:
container_name: hbbr
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
network_mode: "host"
restart: unless-stopped

Then start:

1
2
3
4
5
docker compose up -d
# Enter the ~/rustdesk/data folder
cd data
# View the key
cat id_*.pub

RustDesk installation and configuration

Install by visiting the following link:

After installation, open the network settings, fill in the IP of the ID/relay server (i.e., the IP of the server running Docker) into the ID server and relay server fields. The controlled end may leave the relay server blank, but it is recommended to fill it in for the controlling end. Then, the controlling end fills in the key (the content of the .pub file in the data folder above).

Windows RustDesk network configuration
Windows RustDesk network configuration

Finally, enter the ID and password of the controlled end to connect.