banner
 Sayyiku

Sayyiku

Chaos is a ladder
telegram
twitter

RustDesk Debian Self-built Relay Server

1. Introduction#

An open-source virtual and remote desktop infrastructure. Remote desktop software that is ready to use out of the box without any configuration. You have complete control over your data and don't have to worry about security issues. You can use our registration/relay server, or build your own, or develop your own version.

If you only need to use RustDesk software and don't need to set up your own server, you can directly download the corresponding system version from the official website. However, using the author's shared server may have issues with image quality and response speed. It is recommended that students with their own cloud servers set up their own relay servers, which will greatly improve image quality and response speed.

Software official website: RustDesk

2. Setting up a Relay Server#

This blog is based on Debian 11 and uses pm2 for management.

Basic requirements for building a relay server:

The hardware requirements are very low, the minimum configuration of a cloud server is sufficient, and the CPU and memory requirements are minimal. As for network size, if TCP hole punching fails, relay traffic will be consumed. The traffic of a relay connection is between 30k-3M per second (1920x1080 screen), depending on the clarity settings and screen changes. If it is only for office needs, the average is around 100K/s.

2.1 Downloading Relay Server Software#

2.1.1 Go to the RustDesk official website to download the software#

Official website download link: rustdesk-server. Find the software package that matches your system.

2.1.2 Upload to your own server#

① Create a folder named "rustdesk" in the "/usr/local/lib" directory.

mkdir rustdesk

② Use FTP software to upload the software package to the "/usr/local/lib/rustdesk" directory.

Or use the "wget" command to download directly.

wget https://github.com/rustdesk/rustdesk-server/releases/download/1.1.7-1/rustdesk-server-linux-amd64.zip

③ Unzip the software package.

unzip rustdesk-server-linux-amd64.zip

At this point, the software package is ready to use, but it is recommended to install pm2 for starting and managing the service.

Start command

./hbbs -r <address[:port] of the host where hbbr is running>
./hbbr

2.2 Install nodejs#

① Create a folder named "nodejs" in the "/usr/local/lib" directory.

mkdir nodejs

② Download nodejs from the nodejs official website and upload it to the "/usr/local/lib/nodejs" directory using FTP software.

Or use the "wget" command to download directly.

wget https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz

Note: You need to install nodejs version 16+.

③ Unzip the file and configure symbolic links.

# Unzip the file
tar -xvf node-v16.14.0-linux-x64.tar.xz
# Configure symbolic links
ln -s /usr/local/lib/nodejs/node-v16.14.0-linux-x64/bin/node /usr/local/bin
ln -s /usr/local/lib/nodejs/node-v16.14.0-linux-x64/bin/npm /usr/local/bin

④ Check if the configuration is successful.

node -v
npm -v

2.3 Install the pm2 package and start the service#

① Install pm2 using the npm command.

npm install -g pm2

② Run hbbs/hbbr using pm2.

Go to the directory where the relay software is located and execute the following commands.

pm2 start hbbs -- -r <your-relay-server-ip[:port]>
pm2 start hbbr

③ Check the status of the service.

pm2 list

The "-r" parameter of hbbs is not necessary. It is only for convenience so that you don't have to specify the relay server on the client side. If it is the default port 21117, you can omit the port. The relay server specified on the client side takes precedence over this.

The official website states that it is optional to fill in or not, but it is better to include the parameter.

2.4 Configure the firewall#

Find the firewall or security group configuration of your server and open the following ports as shown in Figure 2-2:

  • TCP (21115, 21116, 21117, 21118, 21119)

  • UDP (21116)

Be sure to open these ports in the firewall. Please note that port 21116 should be opened for both TCP and UDP.

  • hbbs listens on 21115 (tcp), 21116 (tcp/udp), 21118 (tcp);

  • hbbr listens on 21117 (tcp), 21119 (tcp);

  • 21115 is used by hbbs for NAT type testing;

  • 21116/UDP is used by hbbs for ID registration and heartbeat service;

  • 21116/TCP is used by hbbs for TCP hole punching and connection service;

  • 21117 is used by hbbr as a relay service, 21118 and 21119 are for web client support;

  • If you don't need web client support (21118, 21119), the corresponding ports can be closed.

3. Configuration and Usage#

3.1 Connecting without using a key#

Enter the server address configured in the second step into the ID/Relay Server configuration of the RustDesk software, and you can start remote connection after the configuration is completed.

① Open the RustDesk software and find the menu option.

② Configure the ID server and relay server addresses.

Note

① Modify the IP address to your own IP address!!!

Both the connecting and the connected sides need to add relay server configurations!!! (Otherwise, an error of "ID does not exist" will occur)

3.2 Connecting using a key#

After the above configuration is completed, you can already perform normal remote desktop operations and access. However, because the communication is not encrypted, it may be vulnerable to malicious attacks and data theft. Therefore, it is recommended to enable forced key access to the relay address.

① Restart the "hbbs/hbbr" service to enable encrypted connections.

pm2 start hbbs -r <relay-server-ip[:port]> -k _
pm2 start hbbr -k _

② Find the key file.

The key file is configured in the relay software directory as "id_ed25519.pub". Use the following command to view the key.

cat ./id_ed25519.pub

③ Configure the key.

Add the key information to the key option to enable encrypted connections.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.