在 ubuntu 18.04 架設 rustdesk 伺服器 不要使用DOCKER完整詳細步驟

在 ubuntu 18.04 架設 rustdesk 伺服器 不要使用DOCKER完整詳細步驟

在 ubuntu 18.04 架設 rustdesk 伺服器 不要使用DOCKER完整詳細步驟


資料來源: https://gemini.google.com/share/836dad49720d


第一步:系統準備與更新

sudo apt update && sudo apt upgrade -y
sudo apt install wget unzip -y


第二步:下載 RustDesk Server 程式

01.建立安裝目錄

mkdir -p /opt/rustdesk
cd /opt/rustdesk

02.下載並解壓縮(請根據你的 CPU 架構選擇,一般伺服器為 amd64)

# 下載 Linux 64位元版本
wget https://github.com/rustdesk/rustdesk-server/releases/download/1.1.10-3/rustdesk-server-linux-amd64.zip

# 解壓
unzip rustdesk-server-linux-amd64.zip

# 將解壓出的檔案賦予執行權限
chmod +x hbbs hbbr


第三步:使用 Systemd 建立後台服務

01.建立 hbbs 服務

sudo vim /etc/systemd/system/hbbs.service

#vim 使用教學
#i -> 輸入模式
#ESC +:wq -> 寫入並離開
[Unit]
Description=RustDesk ID Server
After=network.target

[Service]
Type=simple
LimitNOFILE=1000000
ExecStart=/opt/rustdesk/hbbs -r 167.86.107.125
WorkingDirectory=/opt/rustdesk
User=root
Restart=always
StandardOutput=append:/var/log/hbbs.log
StandardError=append:/var/log/hbbs.error.log

[Install]
WantedBy=multi-user.target

02.建立 hbbr 服務

sudo vim /etc/systemd/system/hbbr.service
[Unit]
Description=RustDesk Relay Server
After=network.target

[Service]
Type=simple
LimitNOFILE=1000000
ExecStart=/opt/rustdesk/hbbr
WorkingDirectory=/opt/rustdesk
User=root
Restart=always
StandardOutput=append:/var/log/hbbr.log
StandardError=append:/var/log/hbbr.error.log

[Install]
WantedBy=multi-user.target


第四步:啟動服務

01.執行以下指令來加載配置並啟動服務:

sudo systemctl daemon-reload
sudo systemctl enable hbbs hbbr
sudo systemctl start hbbs hbbr

02.檢查狀態:

sudo systemctl status hbbs hbbr


第五步:設定防火牆

sudo ufw allow 21115:21119/tcp
sudo ufw allow 21116/udp


第六步:獲取公鑰 (Key)

cat /opt/rustdesk/id_ed25519.pub

6 thoughts on “在 ubuntu 18.04 架設 rustdesk 伺服器 不要使用DOCKER完整詳細步驟

  1. 如何 透過shell 知道 ubuntu 是否為 amd64

    uname -m

    – x86_64:表示 64位元 (amd64)。
    – i386 or i686:表示 32位元。
    – aarch64:表示 ARM 64位元。

  2. 第七步:客戶端設定
    下載URL: rustdesk客戶端

    進入 設定 -> 網路 -> ID/中繼伺服器。

    ID 伺服器:輸入你的伺服器 IP。

    Key:貼上剛才從 id_ed25519.pub 複製的字串。

    點擊確認即可開始連線。

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

    ID伺服器: 167.86.106.125
    公鑰 (Key)

    @WSXzaq1CEkvkT3ErglZ8jB5WLJUOSj+2vXoIdSXuYOWkMc2GUg=

  3. 常見問題排查

    01.日誌查看:如果無法連線,可以查看 /var/log/hbbs.error.log。
    02.Ubuntu 18.04 限制:雖然 18.04 較舊,但 RustDesk Server 是靜態編譯的二進制文件,通常可以直接運行。如果遇到 GLIBC 版本問題,請考慮升級至 20.04 以上版本。

  4. 01. 伺服器如何手動停止和手動再開啟
    停止服務:

    # 停止 ID 伺服器
    sudo systemctl stop hbbs

    # 停止 中繼伺服器
    sudo systemctl stop hbbr

    開啟服務:

    # 啟動 ID 伺服器
    sudo systemctl start hbbs

    # 啟動 中繼伺服器
    sudo systemctl start hbbr

    重新啟動服務(修改配置後常用):

    sudo systemctl restart hbbs hbbr

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

    02. 伺服器如何置換公鑰 (Key)
    步驟 1:停止服務 在更換金鑰前,必須先停止服務。

    sudo systemctl stop hbbs hbbr

    步驟 2:刪除舊的金鑰檔案 進入你存放 RustDesk 程式的目錄(依據之前的教學是 /opt/rustdesk),刪除以 id_ed25519 開頭的兩個檔案。

    cd /opt/rustdesk
    sudo rm id_ed25519 id_ed25519.pub

    步驟 3:重新啟動服務以生成新 Key 啟動服務後,hbbs 會發現金鑰不見了,進而自動生成一組全新的。

    sudo systemctl start hbbs hbbr

    步驟 4:查看並複製新的公鑰

    cat /opt/rustdesk/id_ed25519.pub

    步驟 5:更新客戶端設定 這步最重要!一旦更換了伺服器的 Key,所有之前連接過的電腦(管理端與受控端)都必須更新為這組新的 Key,否則會出現「Key 不匹配」或「連線關閉」的錯誤。

    額外小叮嚀:
    如果您希望強制所有連線都必須使用 Key 才能連接(提高安全性),請確保您的 hbbs 啟動參數中有包含 -k _。

    在我們之前的 hbbs.service 配置中: ExecStart=/opt/rustdesk/hbbs -r 你的公網IP 若改成: ExecStart=/opt/rustdesk/hbbs -r 你的公網IP -k _ 則沒有填寫正確 Key 的客戶端將完全無法連上您的伺服器。

    1. IP為 167.86.107.125 重新產生一個要強制KEY的hbbs.service 配置


      sudo vim /etc/systemd/system/hbbs.service

      [Unit]
      Description=RustDesk ID Server
      After=network.target

      [Service]
      Type=simple
      LimitNOFILE=1000000
      # -r 指定伺服器地址,-k _ 表示強制客戶端必須輸入正確的 Key 才能連接
      ExecStart=/opt/rustdesk/hbbs -r 167.86.107.125 -k _
      WorkingDirectory=/opt/rustdesk
      User=root
      Restart=always
      StandardOutput=append:/var/log/hbbs.log
      StandardError=append:/var/log/hbbs.error.log

      [Install]
      WantedBy=multi-user.target

jash.liao 發表迴響 取消回覆

你的電子郵件位址並不會被公開。 必要欄位標記為 *