There are plenty of good reasons to use a remote desktop tool outside of work. For starters, it grants access to your powerful home PC (or home lab) on any device from anywhere with a stable internet connection. It also means you can process remote data on a local machine without relying on cloud storage. And when your long-distance family has a thorny tech issue, it’s far easier to troubleshoot over a remote desktop session than over the phone.
For these reasons, I’ve had TeamViewer installed on my PC for as long as I can remember. However, RustDesk, an open-source remote desktop tool, has recently caught my eye — as did the allure of self-hosting a remote desktop server using the RustDesk Open-Source Server (OSS). Since I have a Raspberry Pi (model 4B), it’s perfect for the project; the RustDesk documentation even explicitly mentions it.
Installing the server
It was so much easier on Rasperry Pi than on Windows.
The RustDesk OSS only facilitates the connection and traffic between two remote clients. It itself doesn’t actually let clients remote into it. This is well-suited for the Raspberry Pi because it sips power and can run independently without peripherals. Plus, the Raspberry Pi easily meets the minimal hardware requirements to run the server.
The easiest way to install the RustDesk OSS on the Raspberry Pi OS (and Linux) is using Docker. The entire process takes only three commands in the terminal.
Install Docker with this command:
bash https://get.docker.com)
Followed by this command to install the RustDesk OSS:
wget rustdesk.com/oss.yml -O compose.yml
Then launch the RustDesk Docker instance with this command:
sudo docker compose up -d
After everything finishes executing, test if RustDesk’s hbbs (the signaling server) and hbbr (the relay server) services are running with:
sudo docker logs hbbs
And
sudo docker logs hbbr
They should return their respective status information inside the terminal.
What about on Windows?
That’s almost too easy, right? Well, it’s another story when I tried it on Windows. It isn’t because the process is complex, but rather because RustDesk’s documentation only vaguely guides a novice like me.
Getting the server up and running needs two parts: the RustDesk server itself and the Non-Sucking Service Manager (NSSM), an open-source service helper that keeps the RustDesk server running continuously. I struggled immensely with the setup until I followed this excellent step-by-step guide written by Redditor Zehnpae. It includes many nuanced steps that the official documentation omits. The NSSM download link in the post seems to be broken, but it can easily be acquired from the official NSSM website.
Configuring my network
It needs a few open ports.
The RustDesk OSS needs ports 21115 to 21119 open on the TCP protocol and 21116 open on the UDP protocol. Since I have Uncomplicated Firewall (UFW) installed on my Raspberry Pi, the commands to open them are:
ufw allow 21114:21119/tcp
ufw allow 21116/udp
sudo ufw enable
On Windows, I added the firewall rules for these ports in the Windows Defender Firewall.
Next up is setting up port forwarding in the router to direct external RustDesk traffic to the server. Enter your router’s default gateway and add the rules through its port forwarding configuration section. Each manufacturer has a different interface and default gateway IP, but the required fields are the same.
Setting up the clients
All you need are the server's public encryption key and its IP.
With the server up and running, we can configure the RustDesk clients that will connect to the server.
Download and launch the RustDesk client. Inside it, we need to fill in three fields in its Network section: the ID server, the Relay server, and the Key. Enter the server’s IP address into the ID server field. If you aren’t paying for a static IP, then you’ll need to update it with the dynamic IP every time it changes. And if you don’t have a relay server, just use the same IP address as the ID server.
Next up is finding the public key to put in the “Key” field. RustDesk uses asymmetric encryption, which generates a public and private key pair to encrypt its traffic. To find the public key on the Raspberry Pi, run the sudo docker logs hbbs command again in a terminal. The public key is a string of characters next to the “public key” line. Copy this string into the Key field.
On Windows, the public key is stored in a PUB file named “id_ed25519” under the RustDesk Server install directory. You can view it using a text editor like Notepad. Make sure to select the PUB file and not the generic file under the same name; the other one contains the private key, which should never be given out.
Finally, return to the home tab. If the server and network are set up correctly, it should say “Ready” next to a green dot at the bottom of the window. Repeat the steps above for all the clients you wish to connect.
Using the clients
We’re in the home stretch! To start a remote session, enter the 9-digit ID number of the client you want to control. The number is on the left bar on the RustDesk client’s home page.
How to make this basic setup even better
First and foremost is security. Opening unfettered access to network ports exposes the network to risks, especially to port scanning attacks. In the future, I’m thinking of bolstering the connection security using Tailscale, but that’s a topic for another article.
In terms of performance, Raspberry Pi handily runs the server without any hiccups. RustDesk also provides its own servers to connect its clients, but its availability is spotty compared to self-hosting (it even gives you a warning on its client's home page). On a stable internet connection between two machines, the server’s and clients’ performance easily matches that of TeamViewer. So far, I’ve already been able to successfully help a friend fix a driver issue on his PC using this setup.
So can my self-hosted setup replace TeamViewer? In terms of functionality, absolutely. In terms of security, not yet. If you don’t want to constantly worry about exposing your home network, it can be a good idea to pay for a basic cloud server and run RustDesk OSS there.
