前言
X11 forward 是一種將畫面透過 ssh 從「遠端」顯示至「本地端」的技術
設定遠端
- 修改 ssh_config - 1
sudo vim /etc/ssh/ssh_config
- 修改以下內容:
ForwardX11 yes
- 修改 sshd_config - 2
sudo vim /etc/ssh/sshd_config
- 修改以下內容:
AllowTcpForwarding yes
X11Forwarding yes
X11UseLocalhost yes
設定本地
安裝 ssh,設定 xhost
xhost 表示允許 X 繪圖指令能傳入
通常使用方式:
xhost +HostName
- HostName: 遠端伺服器
如果不知道,可以直接允許全部 (懶人專用、但不安全)
xhost +
連線
ssh -Y pi@192.168.2.133
- ssh -Y :信任的 X11 forwarding 連線 (trusted X11 forwarding)
- ssh -X :不受信任的 X11 forwarding 連線 (untrusted X11 forwarding)
檢查畫面顯示位置
echo $DISPLAY
- 成功顯示範例:
localhost:11.0
Reference
- xhost 和 DISPLAY
- X11 Forwarding SSH
- Connecting remotely to Raspberry Pi over the network using SSH (and X11 forwarding)
- ssh -Y (trusted X11 forwarding) and
ssh -X(untrusted X11 forwarding)?">What is the difference betweenssh -Y(trusted X11 forwarding) andssh -X(untrusted X11 forwarding)? - ssh -X), get
Can’t open displaytrying to run X applications">With SSH X11 forwarding (ssh -X), getCan’t open displaytrying to run X applications - Use X forwarding on a personal computer to securely run graphical applications installed on IU’s research supercomputers
- Raspberry Pi OpenCV 2.4.5 編譯安裝