[Installation] Self-built Rustdesk Server

Article directory

    • RustDesk description
      • RustDesk Advantages
      • RustDesk related links
      • Non-Docker based on CentOS
      • RustDesk default program occupied port description
    • Start hbbr as a relay server
    • Start hbbs which is the ID server
    • Client configuration
    • Write startup script
    • Detailed description of hbbr and hbbs commands

RustDesk description

RustDesk Advantages

  1. Build your own server. Building on your own cloud server is equivalent to exclusive high-speed bandwidth!
  2. Peer-to-peer communication. Once the TCP tunnel function is successfully drilled, it is equivalent to a direct connection between users, without using the server bandwidth!
  3. Letter encryption. After configuring the public key, you must have the public key to use it normally!
  4. Built-in file transfer. Thanks to point-to-point communication, file transfer is also easy!

RustDesk related links

Official introduction: https://rustdesk.com/zh/
Service download address: https://github.com/rustdesk/rustdesk-server/releases
Client download address: https://rustdesk.com/zh/ Supports IOS, Mac, Windows, Android, Linux, etc.!

Non-Docker based on CentOS

[root@VM-4-14-centos rustdesk]# tree
.
└── amd64
    ├── db_v2.sqlite3
    ├── db_v2.sqlite3-shm
    ├── db_v2.sqlite3-wal
    ├── hbbr
    ├── hbbs
    ├── id_ed25519 (This file will not exist at the beginning. It will be automatically generated after startup. If you need to replace it, delete it and restart the service)
    ├── id_ed25519.pub (This file will not exist at the beginning. It will be automatically generated after startup. If you need to replace it, delete it and restart the service)
    └── rustdesk-utils

Description of ports occupied by the default program of RustDesk

hbbs is the ID/Rendezvous server. Default listening: 21115(tcp), 21116(tcp/udp), 21118(tcp)
hbbr is a relay server. Default listening: 21117(tcp), 21119(tcp)
If you only need basic remote control: Please note that 21116 must enable TCP and UDP at the same time.

Among them, 21115 is hbbs used for NAT type testing (no need to turn it on, no need to pay attention)

hbbs: 21116/UDP is hbbs used for ID registration and heartbeat services, 21116/TCP is hbbs used for TCP hole drilling and connection services
hbbr: Only use TCP. 21117 is used by hbbr as a relay service. 21118 and 21119 are to support web clients. If you do not need web client (21118, 21119) support, the port does not need to be opened.

Summary: hbbs needs to specify the port for the client’s ID server and hbbr for the relay server.

Start hbbr as a relay server

Modify the default port of hbbr to 21117 -> 36001 (note that you need to go to the cloud security group and server system firewall square. Note that it is TCP)

-k is the encryption parameter using the fixed _ public key in the id_ed25519.pub file. You can also customize the string for the secret key.

nohup ./hbbr -p 36001 -k _ > hbbr.out 2> & amp;1 & amp;

View hbbr log

[2023-10-31 10:20:19.210728 + 08:00] INFO [src/common.rs:121] Private key comes from id_ed25519
[2023-10-31 10:20:19.210797 + 08:00] INFO [src/relay_server.rs:581] Key: z0woOfOAfIxk5t5JlcFiDFmHMewHcV9KjrhAh4sv2LE=
[2023-10-31 10:20:19.210811 + 08:00] INFO [src/relay_server.rs:60] #blacklist(blacklist.txt): 0
[2023-10-31 10:20:19.210817 + 08:00] INFO [src/relay_server.rs:75] #blocklist(blocklist.txt): 0
[2023-10-31 10:20:19.210819 + 08:00] INFO [src/relay_server.rs:81] Listening on tcp:36001
[2023-10-31 10:20:19.210821 + 08:00] INFO [src/relay_server.rs:83] Listening on websocket :36003
[2023-10-31 10:20:19.210827 + 08:00] INFO [src/relay_server.rs:86] Start
[2023-10-31 10:20:19.210865 + 08:00] INFO [src/relay_server.rs:106] DOWNGRADE_THRESHOLD: 0.66
[2023-10-31 10:20:19.210873 + 08:00] INFO [src/relay_server.rs:115] DOWNGRADE_START_CHECK: 1800s
[2023-10-31 10:20:19.210876 + 08:00] INFO [src/relay_server.rs:124] LIMIT_SPEED: 4Mb/s
[2023-10-31 10:20:19.210878 + 08:00] INFO [src/relay_server.rs:134] TOTAL_BANDWIDTH: 1024Mb/s
[2023-10-31 10:20:19.210880 + 08:00] INFO [src/relay_server.rs:148] SINGLE_BANDWIDTH: 16Mb/s

Start hbbs as the ID server

nohup ./hbbs -r Your IP or domain name: 36001 -p 36000 -k _ > hbbs.out 2> & amp;1 & amp;

hbbs log

[root@linuxcentos rustdesk]# tail -f hbbs.out
[2023-10-31 10:20:32.476159 + 08:00] INFO [src/rendezvous_server.rs:101] Listening on tcp :35999, extra port for NAT test
[2023-10-31 10:20:32.476161 + 08:00] INFO [src/rendezvous_server.rs:102] Listening on websocket :36002
[2023-10-31 10:20:32.476186 + 08:00] INFO [libs/hbb_common/src/udp.rs:35] Receive buf size of udp [::]:36000: Ok(212992)
[2023-10-31 10:20:32.476249 + 08:00] INFO [src/rendezvous_server.rs:137] mask: None
[2023-10-31 10:20:32.476256 + 08:00] INFO [src/rendezvous_server.rs:138] local-ip: ""
[2023-10-31 10:20:32.481969 + 08:00] INFO [src/common.rs:46] relay-servers=["huistudy.cn:36001"]
[2023-10-31 10:20:32.482051 + 08:00] INFO [src/rendezvous_server.rs:154] ALWAYS_USE_RELAY=N
[2023-10-31 10:20:32.482098 + 08:00] INFO [src/rendezvous_server.rs:186] Start
[2023-10-31 10:20:32.482137 + 08:00] INFO [libs/hbb_common/src/udp.rs:35] Receive buf size of udp [::]:0: Ok(212992)
[2023-10-31 10:20:32.483510 + 08:00] INFO [libs/hbb_common/src/udp.rs:35] Receive buf size of udp 0.0.0.0:0: Ok(212992)

After startup is completed, check whether hbbs and hbbr are running normally.

[root@linuxcentos rustdesk]# ps -a | grep hbb
32358 pts/1 00:00:00 hbbr
32374 pts/1 00:00:00 hbbs

If hbbr and hbbs are present, it means normal operation. Continue to configure the client.

Client configuration


Write startup script

vim reloadRustDesk.sh

nohup ./hbbr -p 36001 -k _ > hbbr.out 2> & amp;1 & amp;
nohup ./hbbs -r Your IP or domain name: 36001 -p 36000 -k _ > hbbs.out 2> & amp;1 & amp;

:wqSave and exit

chmod +x reloadRustDesk.sh

Detailed description of hbbr and hbbs commands

hbbr
[root@VM-4-14-centos amd64]# ./hbbr –help
hbbr 1.1.7
Purslane Ltd. [email protected]
RustDesk Relay Server

USAGE:
hbbr [OPTIONS]

FLAGS:
-h, –help print help information
-V, –version print version information

OPTIONS:
-k, –key The client is allowed to connect only if it has the same key.
-p, –port Specify the listening port
copy
copy
hbbs
[root@VM-4-14-centos amd64]# ./hbbs –help
hbbs 1.1.7
Purslane Ltd. [email protected]
RustDesk ID/Rendezvous Server

USAGE:
hbbs [OPTIONS]

FLAGS:
-h, –help print help information
-V, –version print version information

OPTIONS:
-c, –config set custom configuration
-k, –key only allows clients with the same key to remotely target computers. For those who are remote, there is no need to fill in for the time being, only the ID server needs to be filled in!
–mask Determine if the connection comes from LAN, e.g. 192.168.0.0/16
-p, –port Specify the listening port
-r, –relay-servers Sets the default relay servers, separated by colon
-R, –rendezvous-servers Sets rendezvous servers, separated by colon
-M, –rmem Sets UDP recv buffer size, set system rmem_max first, e.g., sudo sysctl -w
net.core.rmem_max=52428800. vi /etc/sysctl.conf, net.core.rmem_max=52428800,
sudo sysctl –p
-s, –serial Sets configure update serial number
-u, –software-url Sets download url of RustDesk software of newest versionCopy
copy
Terminate the RustDesk server
Because the service prefixes all start with hbb (hbbr, hbbs), you can directly query the processes of all hbb commands.

ps -a | grep hbb

Then execute to kill PID

kill -9 PID

Linux starts hbbr and hbbs with one click

“Set the port of the relay server: currently 36001”

nohup ./hbbr -p 36001 -k _ > hbbr.out 2> & amp;1 & amp;
echo "Hbbr is OK!"
sleep 3

“Set the port of the ID server: -r specifies the intermediate server, -p specifies the ID server port”
Example: nohup ./hbbs -r baidu.com:36001 -p 36000 -k _ > hbbs.out 2> & amp;1 & amp;

nohup ./hbbs -r Your relay server IP: the relay port you specified above -p 36000 -k _ > hbbs.out 2> & amp;1 & amp;
echo "Hbbs is OK!"
sleep 3
echo "If there are hbbr and hbbs, it will be started successfully!"
ps -a | grep hbb

refer to:
https://cloud.tencent.com/developer/article/2209494