[VS Code] Remote – SSH + X11 Forwarding
- 2026.01.23
- SSH Ubuntu 22.04 VS Code Windows 11
Windows 端
- 下載 VcXsrV
- 執行 XLaunch:
- 選 Multiple windows
Display Number: 0 - 選 Start no client
✅ Disable access control- Save configuration (
.xlaunch)
- 選 Multiple windows
- 設定環境變數
DISPLAY
PowerShell:setx DISPLAY localhost:0.0 - 重開 PowerShell:
echo $Env:DISPLAY
確認環境變數DISPLAY是否設定成功
開機自動啟動 XLaunch
- Win + R
shell:startup- 開啟
Startup資料夾後
在其中建立.xlaunch的捷徑
Ubuntu 端
- 安裝 xauth
sudo apt updatesudo apt install -y xauth libx11-6
- (X11 狀態確認):
sudo sshd -T | grep -i x11
→x11displayoffset 10
x11forwarding yes
x11uselocalhost yes - 測試
echo $DISPLAY→ 應列出類似localhost:10.0- 用 x11-apps 測試
sudo apt install -y x11-appsxclock
Last Updated on 2026/01/23 by A1go