One-click setup for headless (no monitor) Linux machines to work with RustDesk remote desktop.
Solves two common problems:
- No virtual display — RustDesk can't connect when the monitor is unplugged
- Password every time — Sets a permanent password so you don't need to approve each connection
一鍵設定無螢幕 Linux 主機,讓 RustDesk 遠端桌面正常運作。
解決兩個常見問題:
- 沒有虛擬顯示 — 拔掉螢幕後 RustDesk 無法連線
- 每次都要輸入密碼 — 設定永久密碼,免去每次手動核准
- Ubuntu 20.04+ (and Ubuntu-based: Pop!_OS, Linux Mint, etc.)
- Raspberry Pi OS (Bookworm+)
- Debian
curl -fsSL https://raw.githubusercontent.com/h63016401/rustdesk-headless-setup/main/setup_headless_display.sh | sudo bash -s -- --password YOUR_PASSWORDgit clone https://github.com/h63016401/rustdesk-headless-setup.git
cd rustdesk-headless-setup
sudo ./setup_headless_display.sh --password YOUR_PASSWORDsudo ./setup_headless_display.sh [options]
Options:
--password <pwd> Set RustDesk permanent password / 設定 RustDesk 永久密碼
--skip-rustdesk Skip RustDesk configuration / 跳過 RustDesk 設定
--x11 Force X11 display server (RPi only) / 強制使用 X11(僅 RPi)
--wayland Force Wayland display server (RPi only) / 強制使用 Wayland(僅 RPi)
--hdmi <1|2> HDMI port to target (RPi only, default: 1) / HDMI 埠(僅 RPi,預設:1)
--width <pixels> Width, default: 1920 / 寬度,預設:1920
--height <pixels> Height, default: 1080 / 高度,預設:1080
--refresh <hz> Refresh rate, default: 60 / 更新率,預設:60
--help Show this help / 顯示說明
# Ubuntu - basic setup with RustDesk password
# Ubuntu - 基本設定並設定 RustDesk 密碼
sudo ./setup_headless_display.sh --password mypassword
# Raspberry Pi - X11 mode
# 樹莓派 - X11 模式
sudo ./setup_headless_display.sh --x11 --password mypassword
# Raspberry Pi - custom resolution on HDMI port 2
# 樹莓派 - 自訂解析度,使用 HDMI 埠 2
sudo ./setup_headless_display.sh --hdmi 2 --width 1280 --height 720 --password mypassword
# Only set up virtual display, skip RustDesk
# 只設定虛擬顯示,跳過 RustDesk
sudo ./setup_headless_display.sh --skip-rustdesk- Installs
xserver-xorg-video-dummypackage | 安裝xserver-xorg-video-dummy套件 - Creates X11 config at
/etc/X11/xorg.conf.d/10-headless.confwith a virtual monitor | 建立虛擬螢幕的 X11 設定檔 - Disables Wayland in GDM (dummy driver requires X11) | 關閉 GDM 的 Wayland(dummy 驅動需要 X11)
- Adds
video=HDMI-A-x:WxH@Randvc4.force_hotplug=1to kernel cmdline | 在核心啟動參數加入虛擬顯示設定 - Optionally switches between X11 and Wayland via
raspi-config| 可選擇切換 X11 或 Wayland - Installs an xrandr helper script for X11 mode | 安裝 xrandr 輔助腳本(X11 模式)
- Auto-installs RustDesk if not present (latest version from GitHub) | 若未安裝會自動安裝最新版 RustDesk
- Sets permanent password for unattended access | 設定永久密碼,免核准遠端連線
- Enables and starts the RustDesk service | 啟用並啟動 RustDesk 服務
- Reboot | 重新開機:
sudo reboot - Connect from another machine using your RustDesk ID and the password you set | 從另一台電腦用 RustDesk ID 和設定的密碼連線
MIT