X Window 的Client和Server角色
一般來說如果遠端連線到一台電腦,通常遠端那台電腦是Server,但是對於X Window來說,顯示畫面的才是Server
,因此如果你要遠端觀看遠端的電腦畫面,你手上的電腦是X Server,遠端的電腦是X Client
X Server的Port
當你啟動X Server的時候,他會開始監聽6000port,更詳細的來說X Server會給定display number,而每個display number所監聽的port為6000+display number
X11 forwdarding
如果你的電腦在防火牆後,這時候6000port不一定有打開,而X11 forwdarding不只幫打開一條通道讓遠端電腦可以連到你的6000port,同時還幫你處理好X serve連線的事情。
step1. Ubuntu 安裝x11套件
1 | sudo apt install x11-apps |
step2. 設定遠端電腦開啟x11
修改遠端電腦的/etc/ssh/sshd_config
檔案,確認檔案內X11Forwarding yes
{: w=”350” h=”200” }
step3. 檢查x11設定
用以下指令確認設定正確
1 | sudo cat /etc/ssh/sshd_config |grep -i X11Forwarding |
在Windows下安裝VcXsrv Windows X Server
在windows下必須安裝x server,可以到以下連結下載
https://sourceforge.net/projects/vcxsrv/
問題排除
- Warning: untrusted X11 forwarding setup failed: xauth key data not generated
https://serverfault.com/a/355986
測試
Docker container 透過ssh x11 forwarding傳送影像到遠端電腦
以DeepStream container 為例
1 | docker run --gpus all -it --rm --net=host --privileged -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -w /opt/nvidia/deepstream/deepstream-6.1 nvcr.io/nvidia/deepstream:6.1.1-devel |
參考:
X window解說
https://www.cs.odu.edu/~zeil/cs252/latest/Public/xtrouble/index.html
What You Need to Know About X11 Forwarding
https://goteleport.com/blog/x11-forwarding/
How to enable X11 forwarding from Red Hat Enterprise Linux (RHEL), Amazon Linux, SUSE Linux, Ubuntu server to support GUI-based installations from Amazon EC2
https://aws.amazon.com/tw/blogs/compute/how-to-enable-x11-forwarding-from-red-hat-enterprise-linux-rhel-amazon-linux-suse-linux-ubuntu-server-to-support-gui-based-installations-from-amazon-ec2/
Built-in SSH X11 forwarding in PowerShell or Windows Command Prompt
https://x410.dev/cookbook/built-in-ssh-x11-forwarding-in-powershell-or-windows-command-prompt/
https://dreamanddead.github.io/post/ssh-x11-forward/
https://juejin.cn/post/7009593663894323231
https://zhuanlan.zhihu.com/p/461378596
X11 Forwarding on Windows with Cygwin
https://www.csusb.edu/sites/default/files/cse_x11_forwarding_on_windows_with_cygwin.pdf
Cygwin/X
https://x.cygwin.com/
What exactly is X/Xorg/X11?
https://www.reddit.com/r/linuxquestions/comments/3uh9n9/what_exactly_is_xxorgx11/
SSH X11 Forwarding Of Gnome-Boxes Under Wayland & Mixed Wayland & X11 Environments
https://www.dbts-analytics.com/notesxfwdgb.html
- X11 forwarding docker container裡面的影像
docker run 指令要多加 –volume=”$HOME/.Xauthority:/root/.Xauthority:rw”
X11 forwarding of a GUI app running in docker
https://stackoverflow.com/a/51209546
Run X application in a Docker container reliably on a server connected via SSH without “–net host”
https://stackoverflow.com/questions/48235040/run-x-application-in-a-docker-container-reliably-on-a-server-connected-via-ssh-w