category
Rustdesk
date
Feb 4, 2023
icon
Origin
password
slug
1675490460104
status
Published
summary
前言最近不知怎么,经常需要帮朋友远程,远程工具一般都是用向日葵,不过似乎现在需要登陆才能使用。
tags
docker
rustdesk
type
Post
转载自咕咕鸽
【好玩儿的Docker项目】开箱即用!TeamViewer、向日葵的替代品,20分钟自建一个开源远程桌面服务——RustDesk
2022-07-02/40 评论/18 点赞/12,073 阅读/2,198 字/推送成功!
07/02
温馨提示:
本文最后更新于 2022-07-03,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
前言
最近不知怎么,经常需要帮朋友远程,远程工具一般都是用向日葵,不过似乎现在需要登陆才能使用。
总感觉不是很爽。
今天就来推荐一款向日葵的开源替代品——Rust desk
1. 介绍
一个非常好用的远程桌面软件。
1.1 特点
咕咕这边简单在网上~抄~搜集了一些特点,供大家参考:
- 用Rust编写
- 开箱即用,不需要复杂的配置
- 你可以完全控制你的数据,而不用担心安全问题
- 你可以使用官方的rendezvous/relay服务器,也可以建立你自己的rendezvous/relay服务器。
当然我们今天就是和大家分享一下如何搭建。
2. 项目展示
GitHub原项目地址(感谢作者的付出):https://github.com/rustdesk/rustdesk(23.2k star)
官网地址:https://rustdesk.com
直接丢几个图片:
3. 搭建环境
- 服务器:~腾讯香港轻量应用服务器24元/月VPS一台~展示用的服务器是Netcup特价款,本期搭建用的是斯巴达的服务器,(最好是选 非大陆的服务器 )(腾讯轻量购买链接)Hetzner注册免费得25欧试用金有效期一个月
- 系统:Debian 10(DD脚本 非必需DD用原来的系统也OK)
- 安装好Docker、Docker-compose(相关脚本)
- ~【非必需】提前安装好宝塔面板海外版本aapanel,并安装好Nginx(安装地址)~
- ~【非必需】安装好Nginx Proxy Manager(相关教程)~
服务器要求:
4. 搭建视频
YouTube:https://youtu.be/xQ19DLW4kok
哔哩哔哩【高清版本可以点击去吐槽到B站观看】:
<iframe allowfullscreen="true" class="joe_vplayer" src="https://player.bilibili.com/player.html?bvid=BV1or4y1M7UQ&page=1"></iframe>
5. 搭建方式
5.1 搭建
服务器初始设置,参考
注意:VPS的内存如果过小,建议设置一下SWAP,一般为内存的1-1.5倍即可,可以让系统运行更流畅!
设置SWAP可以用脚本:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">wget</span> -O box.sh https://raw.githubusercontent.com/BlueSkyXN/SKY-BOX/main/box.sh <span class="token operator">&&</span> <span class="token function">chmod</span> +x box.sh <span class="token operator">&&</span> <span class="token function">clear</span> <span class="token operator">&&</span> ./box.sh
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
选择
18
,然后输入你想要扩容的数值即可。<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">sudo</span> -i <span class="token comment"># 切换到root用户</span>
<span class="token function">apt</span> update -y <span class="token comment"># 升级packages</span>
<span class="token function">apt</span> <span class="token function">install</span> <span class="token function">wget</span> <span class="token function">curl</span> <span class="token function">sudo</span> <span class="token function">vim</span> <span class="token function">git</span> <span class="token comment"># Debian系统比较干净,安装常用的软件</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
创建一下安装的目录:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">mkdir</span> -p /root/data/docker_data/rustdesk
<span class="token builtin class-name">cd</span> /root/data/docker_data/rustdesk
<span class="token function">nano</span> docker-compose.yml
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
docker-compose.yml
填入以下内容:<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-yaml line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-yaml"><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span>
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token key atrule">rustdesk-net</span><span class="token punctuation">:</span>
<span class="token key atrule">external</span><span class="token punctuation">:</span> <span class="token boolean important">false</span>
<span class="token key atrule">services</span><span class="token punctuation">:</span>
<span class="token key atrule">hbbs</span><span class="token punctuation">:</span>
<span class="token key atrule">container_name</span><span class="token punctuation">:</span> hbbs
<span class="token key atrule">ports</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> 21115<span class="token punctuation">:</span><span class="token number">21115</span>
<span class="token punctuation">-</span> 21116<span class="token punctuation">:</span><span class="token number">21116</span>
<span class="token punctuation">-</span> 21116<span class="token punctuation">:</span>21116/udp
<span class="token punctuation">-</span> 21118<span class="token punctuation">:</span><span class="token number">21118</span>
<span class="token key atrule">image</span><span class="token punctuation">:</span> rustdesk/rustdesk<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
<span class="token key atrule">command</span><span class="token punctuation">:</span> hbbs <span class="token punctuation">-</span>r hbbs.example.com<span class="token punctuation">:</span><span class="token number">21117</span> <span class="token comment"># hbbs.example.com改成</span>
<span class="token key atrule">volumes</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> ./hbbs<span class="token punctuation">:</span>/root
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> rustdesk<span class="token punctuation">-</span>net
<span class="token key atrule">depends_on</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> hbbr
<span class="token key atrule">restart</span><span class="token punctuation">:</span> unless<span class="token punctuation">-</span>stopped
<span class="token key atrule">hbbr</span><span class="token punctuation">:</span>
<span class="token key atrule">container_name</span><span class="token punctuation">:</span> hbbr
<span class="token key atrule">ports</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> 21117<span class="token punctuation">:</span><span class="token number">21117</span>
<span class="token punctuation">-</span> 21119<span class="token punctuation">:</span><span class="token number">21119</span>
<span class="token key atrule">image</span><span class="token punctuation">:</span> rustdesk/rustdesk<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
<span class="token key atrule">command</span><span class="token punctuation">:</span> hbbr
<span class="token key atrule">volumes</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> ./hbbr<span class="token punctuation">:</span>/root
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> rustdesk<span class="token punctuation">-</span>net
<span class="token key atrule">restart</span><span class="token punctuation">:</span> unless<span class="token punctuation">-</span>stopped
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
没问题的话,
ctrl+x
退出,按y
保存,enter
确认。打开防火墙的端口
21115
、21116
、21117
、21118
、21119
默认情况下,hbbs 监听21115(tcp), 21116(tcp/udp), 21118(tcp),hbbr 监听21117(tcp), 21119(tcp)。
- TCP( 21115, 21116, 21117, 21118, 21119 )
- UDP( 21116 )
查看端口是否被占用(以
21115
为例),输入:<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">lsof</span> -i:21115 <span class="token comment">#查看21115端口是否被占用,如果被占用,重新自定义一个端口</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
如果出现:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash">-bash: lsof: <span class="token builtin class-name">command</span> not found
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
运行:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">apt</span> <span class="token function">install</span> <span class="token function">lsof</span> <span class="token comment">#安装lsof</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
如果端口没有被占用,我们接着可以运行:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token builtin class-name">cd</span> /root/data/docker_data/rustdesk
<span class="token function">docker-compose</span> up -d
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
注意:
5.2 更新
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token function">cp</span> -r /root/data/docker_data/rustdesk /root/data/docker_data/rustdesk.archive <span class="token comment"># 万事先备份,以防万一</span>
<span class="token builtin class-name">cd</span> /root/data/docker_data/rustdesk <span class="token comment"># 进入docker-compose所在的文件夹</span>
<span class="token function">docker-compose</span> pull <span class="token comment"># 拉取最新的镜像</span>
<span class="token function">docker-compose</span> up -d <span class="token comment"># 重新更新当前镜像</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
利用Docker-compose搭建的应用,更新非常容易~
5.3 卸载
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash"><span class="token builtin class-name">cd</span> /root/data/docker_data/rustdesk <span class="token comment"># 进入docker-compose所在的文件夹</span>
<span class="token function">docker-compose</span> down <span class="token comment"># 停止容器,此时不会删除映射到本地的数据</span>
<span class="token function">rm</span> -rf /root/data/docker_data/rustdesk <span class="token comment"># 完全删除映射到本地的数据</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
6. 使用教程
6.1 安装和配置
见咕咕鸽的视频
点击 ID 右侧的菜单按钮如下,选择“ ID/中继服务器”。
在 ID 服务器输入框中(被控端+主控端)输入 hbbs 主机或 ip 地址,另外两个地址可以不填,RustDesk会自动推导(如果没有特别设定),中继服务器指的是hbbr(21116)端口。
例如:
例如:
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash">hbbs.example.com
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
或者
<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-bash line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-bash">hbbs.example.com:21116
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
6.1.1 功能展示
6.1.2 传输文件
6.2 几个小问题
6.2.1 加密通话
默认是不加密的。我们可以通过设置Key,来加密通话。
以下来自官方文档:
hbbs在第一次运行时,会自动产生一对加密私钥和公钥(分别位于运行目录下的
id_ed25519
和id_ed25519.pub
文件中),其主要用途是为了通讯加密。如果您在上一步骤中没有填写
Key:
(公钥文件id_ed25519.pub
中的内容),不影响连接,但是连接无法加密。<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-none line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language- language-none">cat /root/data/docker_data/rustdesk/hbbs/id_ed25519.pub
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
如果您禁止没有key的用户建立非加密连接,请在运行hbbs和hbbr的时候添加
-k _
参数,例如:<pre class="c_title c_hr c_macdot c_hover_tools c_expander c_copy language-yaml line-numbers" tabindex="0"><i class="joe-font joe-icon-arrow-downb code-expander" title="折叠/展开"></i><code class="language-yaml"><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span>
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token key atrule">rustdesk-net</span><span class="token punctuation">:</span>
<span class="token key atrule">external</span><span class="token punctuation">:</span> <span class="token boolean important">false</span>
<span class="token key atrule">services</span><span class="token punctuation">:</span>
<span class="token key atrule">hbbs</span><span class="token punctuation">:</span>
<span class="token key atrule">container_name</span><span class="token punctuation">:</span> hbbs
<span class="token key atrule">ports</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> 21115<span class="token punctuation">:</span><span class="token number">21115</span>
<span class="token punctuation">-</span> 21116<span class="token punctuation">:</span><span class="token number">21116</span>
<span class="token punctuation">-</span> 21116<span class="token punctuation">:</span>21116/udp
<span class="token punctuation">-</span> 21118<span class="token punctuation">:</span><span class="token number">21118</span>
<span class="token key atrule">image</span><span class="token punctuation">:</span> rustdesk/rustdesk<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
<span class="token key atrule">command</span><span class="token punctuation">:</span> hbbs <span class="token punctuation">-</span>r hbbs.example.com<span class="token punctuation">:</span>21117 <span class="token punctuation">-</span>k _ <span class="token comment"># 加上-k _ </span>
<span class="token key atrule">volumes</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> ./hbbs<span class="token punctuation">:</span>/root
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> rustdesk<span class="token punctuation">-</span>net
<span class="token key atrule">depends_on</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> hbbr
<span class="token key atrule">restart</span><span class="token punctuation">:</span> unless<span class="token punctuation">-</span>stopped
<span class="token key atrule">hbbr</span><span class="token punctuation">:</span>
<span class="token key atrule">container_name</span><span class="token punctuation">:</span> hbbr
<span class="token key atrule">ports</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> 21117<span class="token punctuation">:</span><span class="token number">21117</span>
<span class="token punctuation">-</span> 21119<span class="token punctuation">:</span><span class="token number">21119</span>
<span class="token key atrule">image</span><span class="token punctuation">:</span> rustdesk/rustdesk<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
<span class="token key atrule">command</span><span class="token punctuation">:</span> hbbr <span class="token punctuation">-</span>k _ <span class="token comment"># 加上-k _ </span>
<span class="token key atrule">volumes</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> ./hbbr<span class="token punctuation">:</span>/root
<span class="token key atrule">networks</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> rustdesk<span class="token punctuation">-</span>net
<span class="token key atrule">restart</span><span class="token punctuation">:</span> unless<span class="token punctuation">-</span>stopped
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code><span class="copy-button"><i class="joe-font joe-icon-copy" title="复制代码"></i></span></pre>
实测加上-k _参数后,会导致无法连接,不确定是不是BUG,有解决的小伙伴欢迎在评论区留言交流!
如果要更改key,请删除
id_ed25519
和 id_ed25519.pub
文件并重新启动 hbbs/hbbr,hbbs将会产生新的密钥对。6.2.2 把配置放在可执行文件名里 (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
都需要添加,缺少一个就不好使。如果密钥中有无效字符而不能用于文件名,请删除id_ed25519文件并重新启动hbbs/hbbr,id_ed25519.pub文件将被重新生成,请重复操作直到获得有效字符。
7. 结尾
祝大家用得开心,有问题可以去GitHub提Issues,也可以在评论区互相交流探讨。
同时,有能力给项目做贡献的同学,也欢迎积极加入到项目中来,贡献自己的一份力量!
8. 参考资料
- Author:三百斤的窜天猴
- URL:https://esxdidi.com/article/1675490460104
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts