출처: https://rustdesk.com/docs/en/self-host/install/
Install your own server using a simple to run install script
Script is hosted on https://github.com/dinger1986/rustdeskinstall and supported on our Discord.
Currently the script will download and setup the Relay and Signal Servers (hbbr and hbbs), generate configs and host them on a password protected web page for simple deployment to clients.
Requirements
You need to have linux installed, script is tested working with CentOS Linux 7/8, Ubuntu 18/20 and Debian. A server with 1 CPU, 1 GB and 10 GB disk is plenty to run RustDesk.
How to Install the server
Please setup your firewall on your server prior to running the script.
Make sure you have got access via ssh or otherwise setup prior setting up the firewall. The example commands for UFW (Debian based) are:
1 2 3 |
[crayon-66224e9c0b742160356258 inline="true" class="hljs typescript"]ufw allow proto tcp <span class="hljs-keyword">from</span> YOURIP to <span class="hljs-built_in">any</span> port <span class="hljs-number">22</span> |
[/crayon]
If you have UFW installed use the following commands to configure the firewall:
1 2 3 4 5 6 |
[crayon-66224e9c0b750057642166 inline="true" class="hljs apache"]<span class="hljs-attribute">ufw</span> <span class="hljs-literal">allow</span> <span class="hljs-number">21115</span>:<span class="hljs-number">21119</span>/tcp <span class="hljs-attribute">ufw</span> <span class="hljs-literal">allow</span> <span class="hljs-number">8000</span>/tcp <span class="hljs-attribute">ufw</span> <span class="hljs-literal">allow</span> <span class="hljs-number">21116</span>/udp <span class="hljs-attribute">sudo</span> ufw enable |
[/crayon]
Run the following commands:
1 2 3 4 5 |
[crayon-66224e9c0b75c737321375 inline="true" class="hljs nginx"]<span class="hljs-attribute">wget</span> https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/install.sh chmod +x install.sh ./install.sh |
[/crayon]
Install your own server with docker(-compose)
Requirements
You need to have Docker/Podman installed to run a rustdesk-server as a docker container
Docker examples
Linux/amd64
1 2 3 4 5 |
[crayon-66224e9c0b769881136408 inline="true" class="language-bash hljs" data-lang="bash"]sudo docker image pull rustdesk/rustdesk-server sudo docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v `<span class="hljs-built_in">pwd</span>`:/root -td --net=host rustdesk/rustdesk-server hbbs -r <relay-server-ip[:port]> sudo docker run --name hbbr -p 21117:21117 -p 21119:21119 -v `<span class="hljs-built_in">pwd</span>`:/root -td --net=host rustdesk/rustdesk-server hbbr |
Linux/arm64v8
1 2 3 4 5 |
[crayon-66224e9c0b774212784063 inline="true" class="language-bash hljs" data-lang="bash"]sudo docker image pull rustdesk/rustdesk-server:latest-arm64v8 sudo docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v `<span class="hljs-built_in">pwd</span>`:/root -td --net=host rustdesk/rustdesk-server:latest-arm64v8 hbbs -r <relay-server-ip[:port]> sudo docker run --name hbbr -p 21117:21117 -p 21119:21119 -v `<span class="hljs-built_in">pwd</span>`:/root -td --net=host rustdesk/rustdesk-server:latest-arm64v8 hbbr |
--net=host only works on Linux, which makes hbbs/ hbbr see the real incoming IP Address rather than the Container IP (172.17.0.1). If --net=host works fine, the -p options are not used. If on Windows, leave out sudo and --net=host.
Please remove --net=host if you are having connection problems on your platform.
Docker-Compose examples
For running the docker files with the docker-compose.yml as described here you need to have docker-compose installed.
Linux/amd64
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
[crayon-66224e9c0b7a7292980579 inline="true" class="language-yaml hljs" data-lang="yaml"]<span class="hljs-attr">version</span><span class="hljs-attr">:</span> <span class="hljs-string">'3'</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-attr">rustdesk-net</span><span class="hljs-attr">:</span> <span class="hljs-attr">external</span><span class="hljs-attr">:</span> <span class="hljs-literal">false</span> <span class="hljs-attr">services</span><span class="hljs-attr">:</span> <span class="hljs-attr">hbbs</span><span class="hljs-attr">:</span> <span class="hljs-attr">container_name</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbs</span> <span class="hljs-attr">ports</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21115</span><span class="hljs-string">:</span><span class="hljs-string">21115</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21116</span><span class="hljs-string">:</span><span class="hljs-string">21116</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21116</span><span class="hljs-string">:</span><span class="hljs-string">21116</span><span class="hljs-string">/udp</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21118</span><span class="hljs-string">:</span><span class="hljs-string">21118</span> <span class="hljs-attr">image</span><span class="hljs-attr">:</span> <span class="hljs-string">rustdesk/rustdesk-server:latest</span> <span class="hljs-attr">command</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbs</span> <span class="hljs-string">-r</span> <span class="hljs-string">example.com:21117</span> <span class="hljs-attr">volumes</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">./hbbs:/root</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">rustdesk-net</span> <span class="hljs-attr">depends_on</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">restart</span><span class="hljs-attr">:</span> <span class="hljs-string">unless-stopped</span> <span class="hljs-attr">hbbr</span><span class="hljs-attr">:</span> <span class="hljs-attr">container_name</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">ports</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21117</span><span class="hljs-string">:</span><span class="hljs-string">21117</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21119</span><span class="hljs-string">:</span><span class="hljs-string">21119</span> <span class="hljs-attr">image</span><span class="hljs-attr">:</span> <span class="hljs-string">rustdesk/rustdesk-server:latest</span> <span class="hljs-attr">command</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">volumes</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">./hbbr:/root</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">rustdesk-net</span> <span class="hljs-attr">restart</span><span class="hljs-attr">:</span> <span class="hljs-string">unless-stopped</span> |
Linux/arm64v8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
[crayon-66224e9c0b7b5902833581 inline="true" class="language-yaml hljs" data-lang="yaml"]<span class="hljs-attr">version</span><span class="hljs-attr">:</span> <span class="hljs-string">'3'</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-attr">rustdesk-net</span><span class="hljs-attr">:</span> <span class="hljs-attr">external</span><span class="hljs-attr">:</span> <span class="hljs-literal">false</span> <span class="hljs-attr">services</span><span class="hljs-attr">:</span> <span class="hljs-attr">hbbs</span><span class="hljs-attr">:</span> <span class="hljs-attr">container_name</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbs</span> <span class="hljs-attr">ports</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21115</span><span class="hljs-string">:</span><span class="hljs-string">21115</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21116</span><span class="hljs-string">:</span><span class="hljs-string">21116</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21116</span><span class="hljs-string">:</span><span class="hljs-string">21116</span><span class="hljs-string">/udp</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21118</span><span class="hljs-string">:</span><span class="hljs-string">21118</span> <span class="hljs-attr">image</span><span class="hljs-attr">:</span> <span class="hljs-string">rustdesk/rustdesk-server:latest-arm64v8</span> <span class="hljs-attr">command</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbs</span> <span class="hljs-string">-r</span> <span class="hljs-string">example.com:21117</span> <span class="hljs-attr">volumes</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">./hbbs:/root</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">rustdesk-net</span> <span class="hljs-attr">depends_on</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">restart</span><span class="hljs-attr">:</span> <span class="hljs-string">unless-stopped</span> <span class="hljs-attr">hbbr</span><span class="hljs-attr">:</span> <span class="hljs-attr">container_name</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">ports</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21117</span><span class="hljs-string">:</span><span class="hljs-string">21117</span> <span class="hljs-bullet">-</span> <span class="hljs-number">21119</span><span class="hljs-string">:</span><span class="hljs-string">21119</span> <span class="hljs-attr">image</span><span class="hljs-attr">:</span> <span class="hljs-string">rustdesk/rustdesk-server:latest-arm64v8</span> <span class="hljs-attr">command</span><span class="hljs-attr">:</span> <span class="hljs-string">hbbr</span> <span class="hljs-attr">volumes</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">./hbbr:/root</span> <span class="hljs-attr">networks</span><span class="hljs-attr">:</span> <span class="hljs-bullet">-</span> <span class="hljs-string">rustdesk-net</span> <span class="hljs-attr">restart</span><span class="hljs-attr">:</span> <span class="hljs-string">unless-stopped</span> |
Set up your own server instance without using Docker
STEP 1 : Download server-side software programs
Platform versions provided:
- Linux
- Windows
The tutorial below is based on Linux build.
There are two executables and a folder:
- hbbs – RustDesk ID/Rendezvous server
- hbbr – RustDesk relay server
They are built on CentOS Linux 7, tested on CentOS Linux 7/8 and Ubuntu 18/20.
Server Requirements
The hardware requirements are very low; the minimum configuration of a basic cloud server is enough, and the CPU and memory requirements are minimal. You can also use a Raspberry Pi or something similar. Regarding the network size, if the TCP hole punching direct connection fails, the relay traffic will be consumed. The traffic of a relay connection is between 30k-3M/s (1920×1080 screen) depending on the resolution settings and screen update. If it is only for office work demand, the traffic is around 100K/s.
STEP 2 : Run hbbs and hbbr on your server
Option 1
Run hbbs/hbbr on your server (CentOS or Ubuntu). We suggest you use pm2 for managing your service.
1 2 3 4 |
[crayon-66224e9c0b7cd775406724 inline="true" class="language-bash hljs" data-lang="bash"]./hbbs -r <relay-server-ip[:port]> ./hbbr |
Option 2 – pm2
Run hbbs/hbbr with pm2
1 2 3 4 |
[crayon-66224e9c0b7d8915684487 inline="true" class="language-bash hljs" data-lang="bash"]pm2 start hbbs -- -r <relay-server-ip[:port]> pm2 start hbbr |
pm2 requires NodeJS v16+, if you fail to run pm2 (e.g. you can not see hbbs/ hbbr in pm2 list), please download and install the NodeJS LTS version from https://nodejs.org. If you want to make hbbs/ hbbr auto-run after reboot, please check out pm2 save and pm2 startup. More about pm2. Another good tool for your logs is pm2-logrotate.
The -r parameter of hbbs is not mandatory, it is just convenient for you not to specify a relay server on the controlled client side. You do not need to specify port if you are using default 21117 port. The relay server specified by the client has a higher priority than this.
By default, hbbs listens on 21115 (TCP) and 21116 (TCP/UDP), 21118 (TCP), and hbbr listens on 21117 (TCP), 21119 (TCP). Be sure to open these ports in the firewall. Please note that 21116 should be enabled both for TCP and UDP. 21115 is used for the NAT type test, 21116/UDP is used for the ID registration and heartbeat service, 21116/TCP is used for TCP hole punching and connection service, 21117 is used for the Relay services, and 21118 and 21119 are used to support web clients. If you do not need web client (21118, 21119) support, the corresponding ports can be disabled.
- TCP (21115, 21116, 21117, 21118, 21119)
- UDP (21116)
Please run with the -h option to see help if you want to choose your own port.
--net=host only works on Linux, which makes hbbs/ hbbr see the real incoming IP Address rather than the Container IP (172.17.0.1). If --net=host works fine, the -p options are not used. If on Windows, leave out sudo and --net=host.
Please remove --net=host if you are having connection problems on your platform.
STEP 3 : Set hbbs/hbbr address on client-side
Click on the Menu button [ ⋮ ] on the right side of ID as shown below, and choose “ID/Relay Server”.
Enter the hbbs host or IP Address in the ID Server input box (local side + remote side). The other two addresses can be left blank, RustDesk will automatically deduce (if not specially set), and the Relay Server refers to hbbr (port 21117).
e.g.
1 2 3 |
[crayon-66224e9c0b851525148976 inline="true" class="language-nolang" data-lang="nolang"]hbbs.example.com |
[/crayon]
or
1 2 3 |
[crayon-66224e9c0b85a663657641 inline="true" class="language-nolang" data-lang="nolang"]hbbs.example.com:21116 |
Put config in rustdesk.exe file name (Windows only)
Change rustdesk.exe to rustdesk- host=<host-ip-or-name>,key=<public-key-string>.exe, e.g. rustdesk- host=192.168.1.137,key=xfdsfsd32=32.exe. You can see the config result in the About Window below.
You need to set both host and key, missing either one will not work.
If there are invalid characters in the key which can not be used in a Windows file name, please remove the id_ed25519 file from your server and restart hbbs/ hbbr. This will cause the id_ed25519.pub file to regenerate. You may need to repeat this process until you get valid characters.
Menu | About Page |
---|---|
Key
Different from the old version, the key in this version is mandatory, but you don’t need to set it yourself. When hbbs runs for the first time, it will automatically generate a pair of encrypted private and public keys (respectively located in the id_ed25519 and id_ed25519.pub files in the running directory), whose main purpose is for communication encryption.
If you did not fill in the Key: (the content in the public key file id_ed25519.pub) in the previous step, it does not affect the connection, but the connection cannot be encrypted.
1 2 3 |
[crayon-66224e9c0b8ac284245701 inline="true" class="language-bash hljs" data-lang="bash"]cat ./id_ed25519.pub |
If you want to prohibit users without the key from establishing non-encrypted connections, please add the -k _ parameter when running hbbs and hbbr, for example:
1 2 3 4 |
[crayon-66224e9c0b8c5128947777 inline="true" class="language-bash hljs" data-lang="bash"]./hbbs -r <relay-server-ip[:port]> -k _ ./hbbr -k _ |
If you want to change the key, remove the id_ed25519 and id_ed25519.pub files and restart hbbs/ hbbr, hbbs will generate a new key pair.