遠程連接服務器或者工作站的時候,通常不能打開一個GUI圖形用戶,而且在打開過程中會出現諸如:
[root@workstation ~]# firewall-config
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
(firewall-config:2148): Gtk-WARNING **: 15:23:40.595: cannot open display:
或者:
指令名:Cannot connect to display
的提示。那么如何解決這個問題呢?
假設兩台機器的IP地址分別為:
IP-本地(用戶可以未知,但實際怎么可能不知道呢!);
username-本地;
IP-遠程(需已知用戶名和密碼);
username-本地。
遠程機器和本地及其均為Linux系統
本地機器:我的是VMWare里面安裝的RHEL8系統(已經安裝X11圖形界面);
遠程機器:RHEL8多用戶工作站。
保證這兩台機器均可以鏈接以太網(需已知兩台機器的以太網IPv4地址),
當采用SSH命令在本地linux的terminal下鏈接遠程機器時:
[username-本地@IP-本地]$ ssh username@遠程IP username@IP-遠程's passwd:(輸入正確的密碼,通常這個密碼不可見) [username-本地@IP-遠程]$
這樣就連接成功了,但是即便本地機器已經安裝了X11圖形界面,但實際上當輸入一個需要圖形界面的指令時,還是無法打開圖形界面,我用firewall-config做個演示:
[root@workstation ~]# firewall-config
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
(firewall-config:2148): Gtk-WARNING **: 15:23:40.595: cannot open display:
我們需要修改SSH的遠程鏈接方式(-Y):
[username-本地@IP-本地]$ ssh -Y username@遠程IP username-遠程@IP-遠程's passwd:(輸入正確的密碼,通常這個密碼不可見) [username-遠程@IP-遠程]$ firewall-config