[VS Code] Remote – SSH + X11 Forwarding

Windows 端

  1. 下載 VcXsrV
  2. 執行 XLaunch:
    1. 選 Multiple windows
      Display Number: 0
    2. 選 Start no client
    3. ✅ Disable access control
    4. Save configuration (.xlaunch)
  3. 設定環境變數DISPLAY
    PowerShell: setx DISPLAY localhost:0.0
  4. 重開 PowerShell: echo $Env:DISPLAY
    確認環境變數DISPLAY是否設定成功

開機自動啟動 XLaunch

  1. Win + R
  2. shell:startup
  3. 開啟Startup資料夾後
    在其中建立.xlaunch的捷徑

Ubuntu 端

  1. 安裝 xauth
    1. sudo apt update
    2. sudo apt install -y xauth libx11-6
  2. (X11 狀態確認):sudo sshd -T | grep -i x11
    x11displayoffset 10
    x11forwarding yes
    x11uselocalhost yes
  3. 測試
    1. echo $DISPLAY → 應列出類似localhost:10.0
    2. 用 x11-apps 測試
      1. sudo apt install -y x11-apps
      2. xclock

Last Updated on 2026/01/23 by A1go

目錄
Bitnami