How to Install Rustdesk Relay Server on Ubuntu
Written By Arni Johannesson
Last updated About 10 hours ago
Introduction
RustDesk is an open-source remote desktop tool and a popular self-hosted alternative to TeamViewer and AnyDesk. The OSS edition does not include a web management console, but for personal use the server alone is all you need.
Prerequisites
- A clean OS Ubuntu 24.04 server (VPS) with a public IPv4 address
- Optional but recommended: a domain name pointed to your server (e.g. rd.example.com)
- A non-root user with sudo privileges
Ports used by RustDesk
As we don’t use the web client, keep 21118 and 21119 closed in the firewall.
Configure the firewall
On clean OS images UFW is not installed by default. So install it first.
sudo apt install ufwAllow SSH first, so that you don’t lock yourself out when the firewall is enabled:
sudo ufw allow 22/tcpThen open the RustDesk ports:
sudo ufw allow 21115:21117/tcp
sudo ufw allow 21116/udpOnly if you are going to install the optional client-installer web page (see below), also allow port 8000:
sudo ufw allow 8000/tcpEnable the firewall and check the rules:
sudo ufw enable
sudo ufw statusInstall RustDesk Server
Run the following commands:
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh
chmod +x install.sh
./install.shThe script asks two questions:
- IP or DNS/Domain. Choose DNS/Domain and enter your domain (e.g.
rd.example.com) if you have one. A domain keeps your client configuration valid if the server IP ever changes. IP auto-detects the current public IP. - Download configs and install the HTTP server? This installs gohttpserver on port 8000 with preconfigured Windows/Linux client install scripts behind basic authentication. It is served over plain HTTP, so the login and password travel unencrypted. For a minimal setup choose No.
To skip the questions, the script also accepts flags:
./install.sh --resolvedns "rd.example.com" --skip-httpGet the public key
Clients need the server address and the public key. The script prints both at the end, and you can show the key again at any time:
cat /opt/rustdesk/*.pubVerify the installation
Check that both services are running:
sudo systemctl status rustdesksignal rustdeskrelay --no-pagerCheck that the daemons are listening:
sudo ss -lntup | grep -E 'hbbs|hbbr'You should see 21115, 21116 (TCP and UDP) and 21117, plus 21118/21119, which the firewall keeps closed.
Logs are plain files, not journald:
tail -f /var/log/rustdesk/signalserver.log /var/log/rustdesk/relayserver.logErrors go to the signalserver.error and relayserver.error files in the same directory.
tail -f /var/log/rustdesk/signalserver.error /var/log/rustdesk/relayserver.errorConfigure the clients
On every RustDesk client open Settings → Network → ID/Relay server and fill in:
- ID server: your domain or IP (e.g.
rd.example.com) - Key: the public key from the previous step
Leave Relay server and API server empty. RustDesk uses the ID server address for the relay as well.
Update the server
New RustDesk Server releases are published on GitHub.
First check which version you are running:
/opt/rustdesk/hbbs --version
/opt/rustdesk/hbbr --versionBack up the installation directory, including the server key. If you lose the key, every client has to be reconfigured:
sudo cp -a /opt/rustdesk /opt/rustdesk.bak-$(date +%F)Download and run the update script:
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/update.sh
chmod +x update.sh
./update.shIf you installed the server without the HTTP page, the script ends with No directory /opt/gohttp found. This is expected, the update itself has completed.
Confirm the result:
/opt/rustdesk/hbbs --version
sudo systemctl status rustdesksignal rustdeskrelay --no-pagerRoll back
If something goes wrong after an update, stop the services, restore the backup and start them again:
sudo systemctl stop rustdesksignal rustdeskrelay
sudo rsync -a /opt/rustdesk.bak-YYYY-MM-DD/ /opt/rustdesk/
sudo systemctl start rustdesksignal rustdeskrelayUseful commands
Restart the services:
sudo systemctl restart rustdesksignal
sudo systemctl restart rustdeskrelayTroubleshooting
- Clients are stuck on “Connecting…” or show the server as unreachable. Check that
21115–21117/tcpand21116/udpare allowed in UFW and in any provider-side firewall. UDP 21116 is the one most often forgotten. - “Key mismatch” or the client does not accept the server. The key in the client settings must exactly match the output of
cat /opt/rustdesk/*.pub. If you reinstall the server from scratch, a new key is generated. - A service is not running. Look at
sudo systemctl status rustdesksignal rustdeskrelay --no-pagerand at the.errorfiles in/var/log/rustdesk/. - The update script fails right at the start. The script reads the latest version from the GitHub API. If the request is rate-limited or blocked, the version comes back empty. Wait a while and try again.
- Unsupported OS message. The script supports Debian/Ubuntu, RHEL/CentOS and Arch based systems with systemd. On anything else, use the Docker method from the official documentation.
Please reach out to Webdock Support if you need assistance.