Linux 系統設定 xhost 允許遠端連線,適用於搭配 VNC 服務場景。
DISPLAY 環境變數。例:第一個虛擬終端啟動 → export DISPLAY=localhost:1xhost + 放行連線。成功顯示 access control disabled, clients can connect from any host[root@localhost ~]# vncserver
New 'localhost:1 (root)' desktop is localhost:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log
[root@localhost ~]# export DISPLAY=localhost:1
[root@localhost ~]# xhost +
access control disabled, clients can connect from any host
若 xhost 設定異常,可依上述步驟逐一排查。