章工运维 章工运维
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)

章工运维

业精于勤,荒于嬉
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)
  • linux

  • windows

  • 中间件

  • 网络

  • 安全

  • 存储

  • 防火墙

  • 数据库

  • 系统

    • vmware

    • ftp

    • nexus

    • harbor

    • confluence&jira

    • loki

    • sonarqube

    • svn

    • other

    • openldap

    • influxdb

    • wordpress

    • kvm

    • argocd

    • jfrog

    • nextcloud

    • RustDesk

      • rustdesk远程控制服务部署
        • Key
    • mail

    • ghost

  • docker

  • other

  • 监控

  • 运维
  • 系统
  • RustDesk
章工运维
2024-05-25
目录

rustdesk远程控制服务部署

# 步骤1: 下载服务器端软件程序

下载 (opens new window)或者使用docker rustdesk/rustdesk-server (opens new window)。

提供版本:

  • Linux
  • Windows

以下针对Linux版本做使用说明。

有两个可执行文件和一个文件夹:

  • hbbs - RustDesk ID注册服务器
  • hbbr - RustDesk 中继服务器

Linux版本在Centos7构建,在 Centos7/8,Ubuntu 18/20上测试过,Debian系列的发行版本应该都没有问题。如果有其他发行版本需求,请联系我。

# 服务器要求

硬件要求很低,最低配置的云服务器就可以了,CPU和内存要求都是最小的。关于网络大小,如果TCP打洞直连失败,就要耗费中继流量,一个中继连接的流量在30k-3M每秒之间(1920x1080屏幕),取决于清晰度设置和画面变化。如果只是办公需求,平均在100K/s。

# 步骤2: 在服务器上运行 hbbs 和 hbbr

在服务器上运行 hbbs/hbbr (Centos 或 Ubuntu)。建议使用pm2 (opens new window) 管理服务。

./hbbs -r <hbbr运行所在主机的地址[:port]> 
./hbbr
1
2

或者使用 pm2 运行 hbbs/hbbr

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

pm2 需要 nodejs v16+,如果你运行 pm2 失败(例如在 pm2 list 中看不到 hbbs/hbbr),请从 https://nodejs.org (opens new window) 下载并安装 LTS 版本的 nodejs。 如果你想让 hbbs/hbbr 在重启后自动运行,请查看 pm2 save 和 pm2 startup。 更多关于 pm2 (opens new window)。另一个不错的日志工具是 pm2-logrotate (opens new window)。

hhbs的-r参数不是必须的,他只是方便你不用在客户端指定中继服务器,如果是默认21117端口,可以不填port。客户端指定的中继服务器优先级高于这个。

默认情况下,hbbs 监听21115(tcp), 21116(tcp/udp), 21118(tcp),hbbr 监听21117(tcp), 21119(tcp)。务必在防火墙开启这几个端口, 请注意21116同时要开启TCP和UDP。其中21115是hbbs用作NAT类型测试,21116/UDP是hbbs用作ID注册与心跳服务,21116/TCP是hbbs用作TCP打洞与连接服务,21117是hbbr用作中继服务, 21118和21119是为了支持网页客户端。如果您不需要网页客户端(21118,21119)支持,对应端口可以不开。

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

如果你想选择自己的端口,使用 “-h” 选项查看帮助。

# Docker示范

如果你运行 docker 版本时候,要求注册码,说明你下载的是老版本,国内的 docker 镜像缓存没有更新

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
1
2
3
# Docker Compose
version: '3'

networks:
  rustdesk-net:
    external: false

services:
  hbbs:
    container_name: hbbs
    ports:
      - 21115:21115
      - 21116:21116 # 自定义 hbbs 映射端口
      - 21116:21116/udp # 自定义 hbbs 映射端口
    image: docker.cnb.cool/zzppjj/docker-images/rustdesk-server
    command: hbbs -r 添服务器的公网IP:21117 -k _ # 填入个人域名或 IP + hbbr 暴露端口
    volumes:
      - ./data:/root # 自定义挂载目录
    networks:
      - rustdesk-net
    depends_on:
      - hbbr
    restart: unless-stopped
#    deploy:
#      resources:
#        limits:
#          memory: 64M

  hbbr:
    container_name: hbbr
    ports:
      - 21117:21117 # 自定义 hbbr 映射端口
    image: docker.cnb.cool/zzppjj/docker-images/rustdesk-server
    command: hbbr -k _
    volumes:
      - ./data:/root # 自定义挂载目录
    networks:
      - rustdesk-net
    restart: unless-stopped
#    deploy:
#      resources:
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
39
40

据我所知,–net=host 仅适用于 Linux,它让 hbbs/hbbr 可以看到对方真实的ip, 而不是固定的容器ip (172.17.0.1)。 如果–net=host运行正常,-p选项就不起作用了, 可以去掉。

请去掉 –net=host,如果您在非Linux系统上遇到无法连接的问题

# 步骤3: 在客户端设置 hbbs/hbbr 地址

点击 ID 右侧的菜单按钮如下,选择“ ID/中继服务器”。

在 ID 服务器输入框中(被控端+主控端)输入 hbbs 主机或 ip 地址,另外两个地址可以不填,RustDesk会自动推导(如果没有特别设定),中继服务器指的是hbbr(21117)端口。

例如:

hbbs.example.com
1

或者

hbbs.example.com:21116
1

# 把配置放在可执行文件名里 (Windows only)

把rustdesk.exe 修改为 rustdesk-host=<host-ip-or-name>,key=<public-key-string>.exe, 例如: rustdesk-host=192.168.1.137,key=xfdsfsd32=32.exe,你可以在About窗口看到配置结果,如下图所示。

host 和 key 都需要添加,缺少一个就不好使。

If there are invalid characters in the key which can not be used in file name, please remove id_ed25519 file and restart your hbbs/hbbr, the id_ed25519.pub file will be regenerated, please repeat until you get valid characters.

# Key


同上个版本不同,本版本中的key是强制的,但是不用你自己设置。hbbs在第一次运行时,会自动产生一对加密私钥和公钥(分别位于运行目录下的id_ed25519和id_ed25519.pub文件中),其主要用途是为了通讯加密。

如果您在上一步骤中没有填写Key:(公钥文件id_ed25519.pub中的内容),不影响连接,但是连接无法加密。

cat ./id_ed25519.pub
1

如果您禁止没有key的用户建立非加密连接,请在运行hbbs和hbbr的时候添加-k _ 参数,例如:

./hbbs -r <relay-server-ip[:port]> -k _
./hbbr -k _
1
2

如果要更改key,请删除 id_ed25519 和 id_ed25519.pub 文件并重新启动 hbbs/hbbr,hbbs将会产生新的密钥对。


原文链接 (opens new window)

微信 支付宝
上次更新: 2025/02/07, 17:21:54

← 部署nextcloud网盘服务 使用iRedMail在Ubuntu 20.04上搭建邮件服务→

最近更新
01
shell脚本模块集合
05-13
02
生活小技巧(认知版)
04-29
03
生活小技巧(防骗版)
04-29
更多文章>
Theme by Vdoing | Copyright © 2019-2025 | 点击查看十年之约 | 鄂ICP备2024072800号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式