Guest mode. You can read posts without signing up. Comments, ratings, job contacts and your own posts open after you sign up and accept the rules. What is Kommit →

Редакция КоммитРедакция портала
commit e982c81 · 3 days ago
🔄 Updated 2 days ago
Blog

Self-hosted remote desktop with RustDesk: server, clients and a security checklist

🌐 Machine-translated from Russian. Show original

AnyDesk and TeamViewer are convenient until you look at licence costs, where the connection broker lives and who can see your device list. RustDesk is an open-source alternative whose server you can run yourself on a small Linux VPS. This guide walks through the free server (RustDesk Server OSS): what runs where, which ports to open, how to roll out pre-configured clients to a fleet, and what to check before you hand it to the help desk.

ℹ️ Terms change. Versions, features and editions are as of November 2026. Before rolling out, check the official documentation and releases: rustdesk.com/docs, rustdesk-server releases, rustdesk client releases.

In this part:

How it works#

The self-hosted backend is two small services from the same image:

ComponentRolePorts
hbbsID / rendezvous server: device registration, heartbeat, NAT hole punching, telling peers how to reach each other21115/tcp (NAT type test), 21116/tcp+udp (ID registration, heartbeat, hole punching), 21118/tcp (web client)
hbbrRelay: carries the session when a direct peer-to-peer connection is impossible21117/tcp (relay), 21119/tcp (web client)
21114/tcpWeb console — Pro edition only—

A session goes like this: both computers register with hbbs; when a technician connects, hbbs tries to set up a direct connection; if NAT or a firewall blocks it, traffic goes through hbbr. So the relay needs bandwidth, the ID server needs very little.

At the time of writing, the latest server release is 1.1.16 (July 2026) and the latest client is 1.5.3 (November 2026). The server is licensed under AGPL-3.0.

OSS or Pro#

NeedServer OSS (free)Server Pro (paid)
Own ID and relay server✅✅
Encrypted sessions with your own key✅✅
Web console, device management, address book for the team—✅
OIDC, LDAP, 2FA for accounts—✅
API, custom branded client generator—✅
SupportCommunity (docs, Discord)Vendor

For a team of a few technicians, OSS is usually enough. If you need central user management and audit, compare with Pro on the official site.

Step 1. Prepare the server#

A small Linux VPS with a public IP or a DNS name (for example rd.example.com) is enough to start. The relay is the part that consumes traffic, so pick a location close to your users and a plan with sufficient bandwidth.

Open the ports. The official guide uses UFW:

# 21114 is needed only for Pro; 21118/21119 only for the web client (see below)
sudo ufw allow 21115:21117/tcp
sudo ufw allow 21116/udp
sudo ufw allow OpenSSH
sudo ufw enable

The documentation's own example opens the whole 21114:21119/tcp range. We narrow it on purpose: with OSS and without the web client, 21114, 21118 and 21119 are not needed.

⚠️ Do not expose 21118/21119 directly. When the web client ports are open, hbbs/hbbr trust the X-Real-IP and X-Forwarded-For headers without validation, so anyone who reaches those ports can spoof their IP. If you use the web client, publish these ports only through a reverse proxy that sets X-Real-IP, and allow only the proxy to connect to them.

Step 2. Run hbbs and hbbr in Docker#

Docker is the recommended path. Install Docker, then download the official compose file:

bash <(wget -qO- https://get.docker.com)
mkdir -p /opt/rustdesk && cd /opt/rustdesk
wget rustdesk.com/oss.yml -O compose.yml
sudo docker compose up -d

The compose file from the documentation looks like this:

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

Notes:

  • network_mode: host works only on Linux, and it is what lets the servers see the real client IP addresses.
  • For a predictable production setup, pin the image tag to a specific release instead of latest and upgrade deliberately.
  • Logs: docker logs hbbs and docker logs hbbr.

Alternatives from the docs: a systemd install script maintained by a community project, and .deb packages from the releases page (dpkg -i <file>.deb).

Step 3. Keys: the part people get wrong#

On first start, hbbs generates a key pair in its working directory — with the compose file above, in ./data:

FileWhat it isWho may see it
id_ed25519Private keyServer only. Back it up, never share
id_ed25519.pubPublic keyEvery client, as the Key field
db_v2.sqlite3hbbs database (default DB_URL)Server only
cat /opt/rustdesk/data/id_ed25519.pub

How key checking works (from the server's environment variable reference):

Settinghbbshbbr
Default KEY-: load the key pair or generate itempty: no key validation
-k _same as defaultloads the key pair and enables validation

So the relay does not validate keys unless you tell it to. If you want only clients with your key to use the relay, start hbbr with -k _, for example command: hbbr -k _ in compose (both services share ./data, so they use the same pair). The alternative image rustdesk-server-s6 does the same for both services with ENCRYPTED_ONLY=1.

If you lose id_ed25519 and the server generates a new pair, every client will need the new public key. That is why the data directory belongs in your backups.

Step 4. Configure clients#

Each client needs two values: the ID server (hostname or IP of hbbs) and the Key (contents of id_ed25519.pub). The Key is the encryption public key, not a Pro licence key. Relay and API fields can stay empty: the client derives them.

Manually: menu (⋮) next to your ID → Network → unlock with admin rights → fill in ID server and Key.

For more than a handful of machines, configure one client and use Export Server Config in the same screen. You get a config string that can be imported on other machines (Import Server Config) or applied from the command line.

Silent deployment on Windows (run as administrator):

.\rustdesk.exe --silent-install
.\rustdesk.exe --install-service      # if the service is not installed yet
.\rustdesk.exe --config $rustdesk_cfg # config string from Export Server Config
.\rustdesk.exe --password $rustdesk_pw # permanent password, if you use one
.\rustdesk.exe --get-id                # record the ID in your inventory

Linux equivalents: rustdesk --get-id, rustdesk --password …, rustdesk --config …, then systemctl restart rustdesk. On macOS, call the binary inside /Applications/RustDesk.app/Contents/MacOS/.

The official deployment page links a ready PowerShell script that downloads the latest client, installs it, applies the config and prints the ID. Read it before using it, and keep passwords out of scripts stored in shared folders or tickets — generate them per device and save them in your password manager.

Step 5. Tune the relay#

Useful hbbs/hbbr environment variables:

VariableServiceDefaultWhat it does
ALWAYS_USE_RELAYhbbsNY disables direct connections, all traffic via your relay
RELAY-SERVERS (-r)hbbsemptyRelay address sent to clients, if it differs or uses a non-standard port
SINGLE_BANDWIDTHhbbr128 Mb/sNormal cap per relay connection
TOTAL_BANDWIDTHhbbr1024 Mb/sShared cap for all relay connections
LIMIT_SPEEDhbbr32 Mb/sCap after downgrade and for IPs in blacklist.txt
RUST_LOGbothinfoLog level, e.g. debug while troubleshooting

ALWAYS_USE_RELAY=Y is worth considering when policy requires that all sessions pass through infrastructure you control; the price is higher traffic and latency on the VPS.

If the server sits behind NAT and clients in the same office cannot reach it via the public name, see the NAT loopback article in the official docs.

Common problems#

SymptomLikely causeFix
Client cannot register with the ID server21116/udp or 21116/tcp blockedOpen both protocols on the server and any upstream firewall
Connects only within the same networkRelay 21117/tcp closed or wrong relay addressOpen 21117/tcp, set -r if the relay is elsewhere
Clients stop connecting after a server rebuildNew key pair generatedRestore id_ed25519* from backup or roll out the new Key
Strangers use your relayhbbr without key validationRun hbbr with -k _
Wrong client IPs in logsContainer not in host network modeUse network_mode: host on Linux

Security checklist#

  • Only the needed ports are open: 21115–21117/tcp and 21116/udp; 21114 only for Pro; 21118/21119 closed or behind a reverse proxy
  • SSH to the server by key, password login disabled, the OS is updated automatically
  • hbbr validates the key (-k _), clients have the Key field filled in
  • data/ (private key and database) is in encrypted off-site backups; restore was tested once
  • Image tag pinned; you watch the server and client release pages and update on purpose
  • Clients deployed with a config string, not configured by hand by end users
  • Permanent passwords are unique per device and stored in a password manager, never in tickets or chats
  • Users know a technician will never ask them to install a different remote tool from a link in a message
  • There is a written rule for who may connect to which machines and how sessions are announced to users
  • If you need SSO, 2FA, central audit and device lists, you evaluated Server Pro or a managed product rather than bolting it on yourself

Sources#

Comments 02 участника · 1 гость🔒 Rate and discuss after signing up

Comments · 0

No comments yet.Sign in to comment, rate and see all comments.