為什麼我可以將顯示從linux匯出到linux?

為什麼我可以將顯示從linux匯出到linux?

本地機器

[mukesh@centos ~]$ xhost 192.168.4.200
192.168.4.200 being added to access control list

遠端虛擬機

[mukesh@centos ~]$ ssh [email protected]
[email protected]'s password: 
Last login: Fri Jul  7 02:38:07 2017
[user@labipa ~]$ DISPLAY=192.168.1.3:0.0;export DISPLAY
[user@labipa ~]$ firefox
Error: cannot open display: 192.168.1.3:0.0
[user@labipa ~]$ su -
Password: 
Last login: Fri Jul  7 02:47:53 EDT 2017 on pts/1
[root@labipa ~]# cat /etc/ssh/sshd_config | grep X11F
X11Forwarding yes
#   X11Forwarding no

另外,根據http://www.softpanorama.org/Xwindows/Troubleshooting/can_not_open_display.shtml遠端機器

[root@labipa ~]#  netstat -tulpen | grep "\(177\|6000\)"
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      0          50364      1512/Xorg           
tcp6       0      0 :::6000                 :::*                    LISTEN      0          50363      1512/Xorg           
udp        0      0 0.0.0.0:177             0.0.0.0:*                           0          48805      1476/gdm     

contents of  /etc/gdm/custom.conf
[security]
DisallowTCP=false
[xdmcp]
Enable=true

答案1

如果啟用X11轉發在客戶端和伺服器端ssh將自動設定DISPLAY變數(到本地代理)。你不需要設定它,尤其是不要直接設定到機器的IP位址;這將完全繞過該ssh機制。用於echo $DISPLAY驗證顯示是否由 設定ssh

如果您僅在伺服器上啟用 X11 轉送(如圖所示),並且不想一般啟用它,ssh -X則可以在用戶端中基於每次使用啟用它。

相關內容