rustdesk的安装,替代向日葵
修改于 2023年10月21日 > 原文地址 rustdesk.com
(官方的教程还是最好用了)
目前,该脚本将下载和设置中继和信号服务器(hbbr 和 hbbs),生成配置并将它们托管在受密码保护的网页上,以便轻松部署到客户端。
要求
你需要安装Linux,脚本在CentOS Linux 7/8,Ubuntu 18/20和Debian上进行测试。具有 1 个 CPU、1 GB 和 10 GB 磁盘的服务器足以运行 RustDesk。
2024/7/7 最新docker-compose脚本,一键启动
version: '3.8'
networks:
rustdesk-net:
external: false
services:
hbbs:
container_name: hbbs
ports:
- 0.0.0.0:21115:21115
- 0.0.0.0:21116:21116 # 替换 <hbbs_port> 为 21116
- 0.0.0.0:21116:21116/udp # 替换 <hbbs_port> 为 21116
image: rustdesk/rustdesk-server
command: hbbs -r 0.0.0.0:21117 # 填入您的 IP 和 hbbr 暴露端口
volumes:
- $PWD/root:/root # 替换 <mount_path> 为实际挂载目录
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
deploy:
resources:
limits:
memory: 64M
hbbr:
container_name: hbbr
ports:
- 0.0.0.0:21117:21117 # 替换 <hbbr_port> 为 21117
image: rustdesk/rustdesk-server
command: hbbr
volumes:
- $PWD/root:/root # 替换 <mount_path> 为实际挂载目录
networks:
- rustdesk-net
restart: unless-stopped
deploy:
resources:
limits:
memory: 64M
如何安装服务器
请在运行脚本之前在服务器上设置防火墙。
在设置防火墙之前,请确保您已通过 ssh 或其他设置获得访问权限。UFW(基于 Debian)的示例命令是:
ufw allow proto tcp from YOURIP to any port 22
如果安装了 UFW,请使用以下命令配置防火墙: (一定要把端口配置正确,21116端口是udp规则)
把端口打开
ufw allow 21115:21119/tcp
ufw allow 8000/tcp
ufw allow 21116/udp
sudo ufw enable
运行以下命令:
安装脚本,也可以从GitHub下载到服务器上 我用的debian机子,运行到这里就成功了,rustdesk 安装在
/opt/rustdesk
目录下,通过systemd进行进程守护。
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/install.sh
chmod +x install.sh
./install.sh
下面是其他安装方法,我没有测试
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
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 `pwd`:/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 `pwd`:/root -td --net=host rustdesk/rustdesk-server hbbr
Linux/arm64v8
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 `pwd`:/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 `pwd`:/root -td --net=host rustdesk/rustdesk-server:latest-arm64v8 hbbr
--net=host
only works on Linux, which makes / see the real incoming IP Address rather than the Container IP (172.17.0.1). If works fine, the options are not used. If on Windows, leave out and .hbbs
hbbr
--net=host
-p
sudo
--net=host
Please remove if you are having connection problems on your platform.--net=host
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
version: '3'
networks:
rustdesk-net:
external: false
services:
hbbs:
container_name: hbbs
ports:
- 21115:21115
- 21116:21116
- 21116:21116/udp
- 21118:21118
image: rustdesk/rustdesk-server:latest
command: hbbs -r example.com:21117
volumes:
- ./data:/root
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
ports:
- 21117:21117
- 21119:21119
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
networks:
- rustdesk-net
restart: unless-stopped
Linux/arm64v8
version: '3'
networks:
rustdesk-net:
external: false
services:
hbbs:
container_name: hbbs
ports:
- 21115:21115
- 21116:21116
- 21116:21116/udp
- 21118:21118
image: rustdesk/rustdesk-server:latest-arm64v8
command: hbbs -r example.com:21117
volumes:
- ./data:/root
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
ports:
- 21117:21117
- 21119:21119
image: rustdesk/rustdesk-server:latest-arm64v8
command: hbbr
volumes:
- ./data:/root
networks:
- rustdesk-net
restart: unless-stopped
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 serverhbbr
- 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 (1920x1080 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
We suggest you use pm2 for managing your service.
Option 1
Run hbbs/hbbr without pm2
./hbbs -r <relay-server-ip[:port]>
./hbbr
Option 2
Run hbbs/hbbr with pm2
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 / in), please download and install the NodeJS LTS version from hbbs
hbbr
pm2 list
https://nodejs.org. If you want to make / auto-run after reboot, please check out and . More about hbbs
hbbr
pm2 save
pm2 startup
pm2. Another good tool for your logs is pm2-logrotate.
The parameter of 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.-r
hbbs
By default, listens on 21115 (TCP) and 21116 (TCP/UDP), 21118 (TCP), and 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.hbbs
hbbr
- TCP (21115, 21116, 21117, 21118, 21119)
- UDP (21116)
Please run with the option to see help if you want to choose your own port.-h
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 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 (port 21117).hbbs
hbbr
e.g.
hbbs.example.com
or
hbbs.example.com:21116
Put config in rustdesk.exe file name (Windows only)
Change to rustdesk-.exe, e.g. rustdesk-.exe. You can see the config result in the About Window below.rustdesk.exe
host=<host-ip-or-name>,key=<public-key-string>
host=192.168.1.137,key=xfdsfsd32=32
You need to set both and , missing either one will not work.host
key
If there are invalid characters in the key which can not be used in a Windows file name, please remove the file from your server and restart /. This will cause the file to regenerate. You may need to repeat this process until you get valid characters.id_ed25519
hbbs
hbbr
id_ed25519.pub
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 runs for the first time, it will automatically generate a pair of encrypted private and public keys (respectively located in the and files in the running directory), whose main purpose is for communication encryption.hbbs
id_ed25519
id_ed25519.pub
If you did not fill in the (the content in the public key file) in the previous step, it does not affect the connection, but the connection cannot be encrypted.Key:
id_ed25519.pub
If you want to prohibit users without the key from establishing non-encrypted connections, please add the parameter when running and , for example:-k _
hbbs
hbbr
./hbbs -r <relay-server-ip[:port]> -k _
./hbbr -k _
If you want to change the key, remove the and files and restart /, will generate a new key pair.id_ed25519
id_ed25519.pub
hbbs
hbbr
hbbs
If you are using docker-compose and keys don’t exist, the start of containers will create differents keys in hbbs and hbbr folders.
You could create keys manually in hbbs and copy them to hbbr before starting the containers.
Or you could stop the hbbr container and copy the keys from hbbs to the hbbr folder, and then restart the container.
- 原文作者:gwozai
- 原文链接:https://blog.gwozai.com/post/rustdesk_install/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。