引言

前几期视频,鼠标讲了RustDesk服务器的搭建,以及客户端的编译。今天,鼠标讲下API服务器的搭建,该操作需要使用自定义key,所以,咱们用docker一键部署,包括中继服务器及API。

官方API是收费的,这次咱们用到的是Github大佬,开源的第三方API源码,可以实现API的基本功能,以及Web远控端,有条件的给大佬点个stars,支持下!

准备工作

1. Linux云服务器一台

在服务器控制台安全组(防火墙)放行如下端口

TCP:21114-21119
UDP:21116

如果服务器同时安装了防火墙,我们需要将防火墙完全关闭,或者放行以上端口,具体方法可自行度娘。

2. WindTerm

SSH工具,用来连接云服务器,可以在这篇文章中下载。

小白零基础编译RustDesk客户端 将服务器等信息内置 告别填写繁琐

小白零基础编译RustDesk客户端 将服务器等信息内置 告别填写繁琐

5
引言 之前讲了手搓远程桌面协助软件,也就RustDeskID/中继服务器的搭建。今天,鼠标讲下,如何将服务器…

安装1Panel服务器管理面板

因为用到docker,图形化操作更简便一些,1Panel这个免费开源的服务器管理面板,是个不错的选择!

1. SSH连接服务器

2. 切换root用户

sudo -s

3. 运行一键安装1Panel脚本

#根据自己的系统选择脚本

#RedHat / CentOS
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sh quick_start.sh

#Ubuntu
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh

#Debian
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh

安装过程参考:

ubuntu@VM-16-8-ubuntu:~$ sudo -s                   #切换root用户
root@VM-16-8-ubuntu:/home/ubuntu# cd               #切换到主目录
root@VM-16-8-ubuntu:~# curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh         #1Panel一键安装脚本
开始下载 1Panel v1.10.18-lts 版本在线安装包
安装包下载地址: https://resource.fit2cloud.com/1panel/package/stable/v1.10.18-lts/release/1panel-v1.10.18-lts-linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 40.8M  100 40.8M    0     0  15.4M      0  0:00:02  0:00:02 --:--:-- 15.4M
Warning: Got more output options than URLs
1panel-v1.10.18-lts-linux-amd64/1panel.service
1panel-v1.10.18-lts-linux-amd64/1pctl
1panel-v1.10.18-lts-linux-amd64/LICENSE
1panel-v1.10.18-lts-linux-amd64/README.md
1panel-v1.10.18-lts-linux-amd64/install.sh
1panel-v1.10.18-lts-linux-amd64/1panel

 ██╗    ██████╗  █████╗ ███╗   ██╗███████╗██╗     
███║    ██╔══██╗██╔══██╗████╗  ██║██╔════╝██║     
╚██║    ██████╔╝███████║██╔██╗ ██║█████╗  ██║     
 ██║    ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝  ██║     
 ██║    ██║     ██║  ██║██║ ╚████║███████╗███████╗
 ╚═╝    ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═══╝╚══════╝╚══════╝
[1Panel Log]: ======================= 开始安装 ======================= 
设置 1Panel 安装目录(默认为/opt):
[1Panel Log]: 您选择的安装路径为 /opt 
[1Panel Log]: ... 在线安装 docker 
[1Panel Log]: 选择延迟最低的源 https://mirrors.tencent.com/docker-ce,延迟为 0.039213 秒 
[1Panel Log]: 尝试从备选链接 https://get.docker.com 下载 Docker 安装脚本... 
[1Panel Log]: 成功从 https://get.docker.com 下载安装脚本 
# Executing docker install script, commit: 39040d838e8bcc48c23a0cc4117475dd15189976
+ sh -c apt-get -qq update >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get -y -qq install ca-certificates curl >/dev/null
+ sh -c install -m 0755 -d /etc/apt/keyrings
+ sh -c curl -fsSL "https://mirrors.tencent.com/docker-ce/linux/ubuntu/gpg" -o /etc/apt/keyrings/docker.asc
+ sh -c chmod a+r /etc/apt/keyrings/docker.asc
+ sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.tencent.com/docker-ce/linux/ubuntu noble stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get -qq update >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get -y -qq install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
 Version:           27.3.1
 API version:       1.47
 Go version:        go1.22.7
 Git commit:        ce12230
 Built:             Fri Sep 20 11:40:59 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.3.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.7
  Git commit:       41ca978
  Built:            Fri Sep 20 11:40:59 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.22
  GitCommit:        7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
 runc:
  Version:          1.1.14
  GitCommit:        v1.1.14-0-g2c9f560
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

================================================================================

To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:

    dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.


To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent
         to root access on the host. Refer to the 'Docker daemon attack surface'
         documentation for details: https://docs.docker.com/go/attack-surface/

================================================================================

[1Panel Log]: docker 安装成功 
Synchronizing state of docker.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable docker
是否配置镜像加速?(y/n): y                           #输入y配置镜像加速
[1Panel Log]: 创建新的配置文件 /etc/docker/daemon.json... 
[1Panel Log]: 镜像加速配置已添加。 
[1Panel Log]: 正在重启 Docker 服务... 
[1Panel Log]: Docker 服务已成功重启。 
[1Panel Log]: ... 在线安装 docker-compose 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 59.8M  100 59.8M    0     0  13.9M      0  0:00:04  0:00:04 --:--:-- 13.9M
[1Panel Log]: docker-compose 安装成功 
设置 1Panel 端口(默认为23281):                    #配置默认端口
[1Panel Log]: 您设置的端口为:23281 
[1Panel Log]: 防火墙开放 23281 端口 
Rules updated
Rules updated (v6)
Firewall not enabled (skipping reload)
设置 1Panel 安全入口(默认为d90044baab):           #配置安全入口
[1Panel Log]: 您设置的面板安全入口为:d90044baab 
设置 1Panel 面板用户(默认为3ef597857b):smianao    #设置面板用户名
[1Panel Log]: 您设置的面板用户为:smianao 
[1Panel Log]: 设置 1Panel 面板密码,设置完成后直接回车以继续(默认为34675a398e): 
*********                                           #设置面板密码
[1Panel Log]: 配置 1Panel Service 
Created symlink /etc/systemd/system/multi-user.target.wants/1panel.service → /etc/systemd/system/1panel.service.
[1Panel Log]: 启动 1Panel 服务 
[1Panel Log]: 1Panel 服务启动成功! 
[1Panel Log]:  
[1Panel Log]: =================感谢您的耐心等待,安装已经完成================== 
[1Panel Log]:  
[1Panel Log]: 请用浏览器访问面板: 
[1Panel Log]: 外网地址: http://62.234.98.8:23281/d90044baab 
[1Panel Log]: 内网地址: http://10.0.16.8:23281/d90044baab 
[1Panel Log]: 面板用户: smianao 
[1Panel Log]: 面板密码: 123456789 
[1Panel Log]:  
[1Panel Log]: 项目官网: https://1panel.cn 
[1Panel Log]: 项目文档: https://1panel.cn/docs 
[1Panel Log]: 代码仓库: https://github.com/1Panel-dev/1Panel 
[1Panel Log]:  
[1Panel Log]: 如果使用的是云服务器,请至安全组开放 23281 端口 
[1Panel Log]:  
[1Panel Log]: 为了您的服务器安全,在您离开此界面后您将无法再看到您的密码,请务必牢记您的密码。 
[1Panel Log]:  
[1Panel Log]: ================================================================ 
root@VM-16-8-ubuntu:~# 

安装过程,根据提示输入信息

Docker编排服务器及API

1. 访问1Panel管理面板

登录信息在上一步安装过程中

2. 创建docke容器

  • 导航菜单点击容器,依次点击编排-创建编排
  • 文件名随意命名,后缀为.yaml
  • 粘贴如下代码,修改IP及key信息,并点击确认开始编排。
networks:
  rustdesk-net:
    external: false
services:
  hbbs:
    container_name: hbbs
    ports:
      - 21115:21115
      - 21116:21116 # 自定义 hbbs 映射端口
      - 21116:21116/udp # 自定义 hbbs 映射端口
      - 21118:21118 # web client
    image: rustdesk/rustdesk-server
    command: hbbs -r <你的服务器IP/域名>:21117 -k <自定义key> # 填入个人域名或 IP + hbbr 暴露端口 并输入自定key
    volumes:
      - /data/rustdesk/hbbs:/root # 自定义挂载目录
    networks:
      - rustdesk-net
    depends_on:
      - hbbr
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 64M
  hbbr:
    container_name: hbbr
    ports:
      - 21117:21117 # 自定义 hbbr 映射端口
      - 21119:21119 # web client
    image: rustdesk/rustdesk-server
    command: hbbr -k <自定义key> #输入自定义key
    #command: hbbr
    volumes:
      - /data/rustdesk/hbbr:/root # 自定义挂载目录
    networks:
      - rustdesk-net
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 64M
  rustdesk-api:
    container_name: rustdesk-api
    environment:
      - TZ=Asia/Shanghai
      - RUSTDESK_API_RUSTDESK_ID_SERVER=<你的服务器IP/域名>:21116 #输入你的服务器IP/域名
      - RUSTDESK_API_RUSTDESK_RELAY_SERVER=<你的服务器IP/域名>:21117 #输入你的服务器IP/域名
      - RUSTDESK_API_RUSTDESK_API_SERVER=http://<你的服务器IP/域名>:21114 #输入你的服务器IP/域名
      - RUSTDESK_API_RUSTDESK_KEY=<自定义key> #输入自定义key
    ports:
      - 21114:21114
    image: lejianwen/rustdesk-api
    volumes:
      - /data/rustdesk/api:/app/data #将数据库挂载出来方便备份
    networks:
      - rustdesk-net
    restart: unless-stopped

通过以上操作,我们直接在docker里创建了服务器和API容器,ID/中继服务器可以直接使用!

编排过程参考:

 hbbr Pulling 
 rustdesk-api Pulling 
 hbbs Pulling 
 d78b354191df Pulling fs layer 
 d50eeecf3075 Pulling fs layer 
 d10949b88d3a Pulling fs layer 
 43c4264eed91 Pulling fs layer 
 48df69c0b6bc Pulling fs layer 
 7f0a66f8299c Pulling fs layer 
 e14685bc2bbd Pulling fs layer 
 4f4fb700ef54 Pulling fs layer 
 43c4264eed91 Waiting 
 48df69c0b6bc Waiting 
 7f0a66f8299c Waiting 
 e14685bc2bbd Waiting 
 4f4fb700ef54 Waiting 
 d78b354191df Pulling fs layer 
 d50eeecf3075 Pulling fs layer 
 d10949b88d3a Pulling fs layer 
 d10949b88d3a Downloading [==================================================>]      94B/94B
 d10949b88d3a Verifying Checksum 
 d10949b88d3a Download complete 
 d10949b88d3a Verifying Checksum 
 d10949b88d3a Download complete 
 d50eeecf3075 Downloading [>                                                  ]  27.96kB/2.791MB
 d50eeecf3075 Downloading [>                                                  ]  27.96kB/2.791MB
 d50eeecf3075 Downloading [=>                                                 ]  58.11kB/2.791MB
 d50eeecf3075 Downloading [=>                                                 ]  58.11kB/2.791MB
 d78b354191df Downloading [>                                                  ]  47.02kB/4.664MB
 d78b354191df Downloading [>                                                  ]  47.02kB/4.664MB
 d50eeecf3075 Downloading [==>                                                ]  118.5kB/2.791MB
 d50eeecf3075 Downloading [==>                                                ]  118.5kB/2.791MB
 d78b354191df Downloading [=>                                                 ]    143kB/4.664MB
 d78b354191df Downloading [=>                                                 ]    143kB/4.664MB
 d50eeecf3075 Downloading [====>                                              ]  249.1kB/2.791MB
 d50eeecf3075 Downloading [====>                                              ]  249.1kB/2.791MB
 d78b354191df Downloading [===>                                               ]  294.1kB/4.664MB
 d78b354191df Downloading [===>                                               ]  294.1kB/4.664MB
 d50eeecf3075 Downloading [=======>                                           ]  412.9kB/2.791MB
 d50eeecf3075 Downloading [=======>                                           ]  412.9kB/2.791MB
 d78b354191df Downloading [=====>                                             ]  490.7kB/4.664MB
 d78b354191df Downloading [=====>                                             ]  490.7kB/4.664MB
 d50eeecf3075 Downloading [============>                                      ]  675.1kB/2.791MB
 d50eeecf3075 Downloading [============>                                      ]  675.1kB/2.791MB
 d78b354191df Downloading [========>                                          ]  834.8kB/4.664MB
 d78b354191df Downloading [========>                                          ]  834.8kB/4.664MB
 d50eeecf3075 Downloading [===================>                               ]  1.101MB/2.791MB
 d50eeecf3075 Downloading [===================>                               ]  1.101MB/2.791MB
 43c4264eed91 Downloading [>                                                  ]  37.15kB/3.624MB
 d78b354191df Downloading [==============>                                    ]  1.326MB/4.664MB
 d78b354191df Downloading [==============>                                    ]  1.326MB/4.664MB
 d50eeecf3075 Downloading [================================>                  ]  1.822MB/2.791MB
 d50eeecf3075 Downloading [================================>                  ]  1.822MB/2.791MB
 43c4264eed91 Downloading [=>                                                 ]  77.13kB/3.624MB
 d78b354191df Downloading [=======================>                           ]  2.211MB/4.664MB
 d78b354191df Downloading [=======================>                           ]  2.211MB/4.664MB
 d50eeecf3075 Download complete 
 d50eeecf3075 Download complete 
 43c4264eed91 Downloading [=>                                                 ]  114.1kB/3.624MB
 d78b354191df Downloading [======================================>            ]  3.608MB/4.664MB
 d78b354191df Downloading [======================================>            ]  3.608MB/4.664MB
 d78b354191df Download complete 
 d78b354191df Download complete 
 d78b354191df Extracting [>                                                  ]  65.54kB/4.664MB
 d78b354191df Extracting [>                                                  ]  65.54kB/4.664MB
 43c4264eed91 Downloading [===>                                               ]  228.3kB/3.624MB
 d78b354191df Extracting [==========================================>        ]  3.932MB/4.664MB
 d78b354191df Extracting [==========================================>        ]  3.932MB/4.664MB
 d78b354191df Extracting [==================================================>]  4.664MB/4.664MB
 d78b354191df Extracting [==================================================>]  4.664MB/4.664MB
 d78b354191df Pull complete 
 d78b354191df Pull complete 
 d50eeecf3075 Extracting [>                                                  ]  32.77kB/2.791MB
 d50eeecf3075 Extracting [>                                                  ]  32.77kB/2.791MB
 43c4264eed91 Downloading [=====>                                             ]  375.7kB/3.624MB
 d50eeecf3075 Extracting [==================================================>]  2.791MB/2.791MB
 d50eeecf3075 Extracting [==================================================>]  2.791MB/2.791MB
 d50eeecf3075 Pull complete 
 d50eeecf3075 Pull complete 
 d10949b88d3a Extracting [==================================================>]      94B/94B
 d10949b88d3a Extracting [==================================================>]      94B/94B
 d10949b88d3a Extracting [==================================================>]      94B/94B
 d10949b88d3a Extracting [==================================================>]      94B/94B
 d10949b88d3a Pull complete 
 d10949b88d3a Pull complete 
 43c4264eed91 Downloading [========>                                          ]  621.5kB/3.624MB
 hbbs Pulled 
 hbbr Pulled 
 43c4264eed91 Downloading [==============>                                    ]  1.015MB/3.624MB
 43c4264eed91 Downloading [======================>                            ]  1.654MB/3.624MB
 43c4264eed91 Downloading [=====================================>             ]  2.734MB/3.624MB
 43c4264eed91 Verifying Checksum 
 43c4264eed91 Download complete 
 43c4264eed91 Extracting [>                                                  ]  65.54kB/3.624MB
 7f0a66f8299c Downloading [>                                                  ]  8.214kB/690.4kB
 48df69c0b6bc Downloading [==================================================>]      93B/93B
 48df69c0b6bc Verifying Checksum 
 48df69c0b6bc Download complete 
 43c4264eed91 Extracting [==================================================>]  3.624MB/3.624MB
 43c4264eed91 Pull complete 
 48df69c0b6bc Extracting [==================================================>]      93B/93B
 48df69c0b6bc Extracting [==================================================>]      93B/93B
 7f0a66f8299c Downloading [===>                                               ]   49.2kB/690.4kB
 48df69c0b6bc Pull complete 
 7f0a66f8299c Downloading [========>                                          ]    111kB/690.4kB
 7f0a66f8299c Downloading [===============>                                   ]  217.8kB/690.4kB
 7f0a66f8299c Downloading [========================>                          ]  344.1kB/690.4kB
 7f0a66f8299c Downloading [========================================>          ]  557.1kB/690.4kB
 7f0a66f8299c Verifying Checksum 
 7f0a66f8299c Download complete 
 7f0a66f8299c Extracting [==>                                                ]  32.77kB/690.4kB
 7f0a66f8299c Extracting [==================================================>]  690.4kB/690.4kB
 4f4fb700ef54 Downloading [==================================================>]      32B/32B
 4f4fb700ef54 Verifying Checksum 
 4f4fb700ef54 Download complete 
 7f0a66f8299c Pull complete 
 e14685bc2bbd Downloading [>                                                  ]  177.4kB/17.53MB
 e14685bc2bbd Downloading [=>                                                 ]  357.1kB/17.53MB
 e14685bc2bbd Downloading [==>                                                ]  717.5kB/17.53MB
 e14685bc2bbd Downloading [===>                                               ]  1.258MB/17.53MB
 e14685bc2bbd Downloading [======>                                            ]  2.163MB/17.53MB
 e14685bc2bbd Downloading [==========>                                        ]  3.609MB/17.53MB
 e14685bc2bbd Downloading [================>                                  ]  5.956MB/17.53MB
 e14685bc2bbd Downloading [=========================>                         ]   9.02MB/17.53MB
 e14685bc2bbd Downloading [==================================>                ]  12.08MB/17.53MB
 e14685bc2bbd Downloading [=========================================>         ]   14.6MB/17.53MB
 e14685bc2bbd Downloading [=================================================> ]  17.49MB/17.53MB
 e14685bc2bbd Verifying Checksum 
 e14685bc2bbd Download complete 
 e14685bc2bbd Extracting [>                                                  ]  196.6kB/17.53MB
 e14685bc2bbd Extracting [================>                                  ]  5.702MB/17.53MB
 e14685bc2bbd Extracting [==============================>                    ]  10.81MB/17.53MB
 e14685bc2bbd Extracting [==========================================>        ]  14.75MB/17.53MB
 e14685bc2bbd Extracting [==================================================>]  17.53MB/17.53MB
 e14685bc2bbd Pull complete 
 4f4fb700ef54 Extracting [==================================================>]      32B/32B
 4f4fb700ef54 Extracting [==================================================>]      32B/32B
 4f4fb700ef54 Pull complete 
 rustdesk-api Pulled 
 Network rustdeskyaml_rustdesk-net  Creating
 Network rustdeskyaml_rustdesk-net  Created
 Container rustdesk-api  Creating
 Container hbbr  Creating
 Container hbbr  Created
 Container hbbs  Creating
 Container rustdesk-api  Created
 Container hbbs  Created
 Container hbbr  Starting
 Container rustdesk-api  Starting
 Container hbbr  Started
 Container hbbs  Starting
 Container rustdesk-api  Started
 Container hbbs  Started
docker-compose up successful!

API的使用

1. 后台管理

http://<你的服务器IP/域名>:21114

以上地址访问API后台,默认用户名和密码为:admin,可以进行添加用户,设备管理等操作!

2. 客户端使用

http://<你的服务器IP/域名>:21114
  • 打开网络设置,将如上地址,填入API项里,点击“应用”
  • 账户设置,点击登录,使用API账户登录,即可同步信息。

3. Web客户端使用

首次登录API后台,会自动同步服务器等信息,web客户端使用方法,同客户端大同小异

结束语

官方API是收费项目,通过这个第三方API,我们可以很便捷的管理我们远程设备;同时,Web端让我们随时随地,对被控电脑,进行远控操作,即使是在无法安装客户端的情况。本期视频就到这里,下期视频,鼠标教你,如何修改RustDersk的ID。点个关注,防止迷路!我是鼠标,谢谢您的观看!