當(dāng)前位置:首頁 > IT技術(shù) > 系統(tǒng)服務(wù) > 正文

通過MacOS的ssh遠(yuǎn)程打開linux的firefox(通過X11協(xié)議實(shí)現(xiàn)圖形化顯示)
2021-09-23 14:03:39

1)X11有兩個(gè)部分組成,一個(gè)是X server,一個(gè)是X client;

  --運(yùn)行在Mac上的是X server,Xserver主要負(fù)責(zé)顯示用戶界面,管理顯示器以及鼠標(biāo)和鍵盤,把相關(guān)的動(dòng)作告訴X client,通常比較多的Xserver是:windows的Xming和MobaXterm,MAC有Xquartz,以及其他各種Xserver的應(yīng)用。

  --運(yùn)行在遠(yuǎn)端機(jī)器上的是X client,X client負(fù)責(zé)程序邏輯,X client根據(jù)程序預(yù)先設(shè)定的邏輯,告訴X server ,請(qǐng)?jiān)谶@了點(diǎn)擊鼠標(biāo),同時(shí)也就是sshd,ssh server的機(jī)器;

2)X11的協(xié)議

X11 Forwarding實(shí)現(xiàn)

?

3)X11實(shí)現(xiàn),大部分情況下Xserver和Xclient在同一臺(tái)機(jī)器上,看起來沒有什么,但是X server和Xclient完全可以運(yùn)行在不同的機(jī)器上,只要彼此通過X協(xié)議通信即可。我們可以通SSH的X11 forwarding轉(zhuǎn)發(fā)實(shí)現(xiàn),遠(yuǎn)程機(jī)器運(yùn)行GUI程序(Xclient),在本地顯示(X server)

?

?


?

關(guān)于如何在Mac操作系統(tǒng)上實(shí)現(xiàn)X11的 Xserver展示遠(yuǎn)端linux或者其他機(jī)器上的Xclient應(yīng)用程序,具體可以參考如下鏈接:https://www.cyberciti.biz/faq/apple-osx-mountain-lion-mavericks-install-xquartz-server/?具體的過程可以大致分成幾個(gè)部分:

1. 需要安裝X server,我們通??梢酝ㄟ^安裝XQuartz來實(shí)現(xiàn),

  方法1,直接下載安裝即可:Visit?this page and download?XQuarz server for macOS. Once downloaded the XQuarz package, install the server by double clicking the package icon in your Downloads folder. Please follow the instructions on-screen to complete the installations:

  方法2:通過brew install --cask xquartz來實(shí)現(xiàn):Another option is to?install Homebrew on macOS?to use the brew package manager as follows using the Termaial app:

2.?安裝完成之后,請(qǐng)重啟電腦

3. 關(guān)于server端的sshd和本地的ssh config的配置文件如何配置,可以參考:https://www.jianshu.com/p/24663f3491fa

?遠(yuǎn)程的sshd配置:

你需要在你的遠(yuǎn)程CentOS主機(jī)上配置OpenSSH服務(wù),啟用X11 Forwarding。在OpenSSH的配置文件中(/etc/ssh/sshd_config),打開如下兩項(xiàng):

1 AllowTcpForwarding yes
2 X11Forwarding yes

?

?

在Ubuntu桌面下,對(duì)OpenSSH-Client的配置文件(/etc/ssh/ssh_config)修改,打開如下三項(xiàng):

1 ForwardAgent yes
2 ForwardX11 yes
3 ForwardX11Trusted yes

?

4)典型的Xclient:

  xeyes xclock firefox 等等

?

6)動(dòng)手操作:

?

?

?

1. ssh -X user@remote-server?

2. ssh -Y user@remote-server

3. ssh -YC4 user@remote-server

可以參考:為什么Firefox在SSH上這么慢?

最佳答案

默認(rèn)的ssh設(shè)置會(huì)導(dǎo)致連接速度很慢。請(qǐng)嘗試以下方法:

ssh -YC4c arcfour,blowfish-cbc user@hostname firefox -no-remote

使用的選項(xiàng)是:

-Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
         subjected to the X11 SECURITY extension controls.
 -C      Requests compression of all data (including stdin, stdout,
         stderr, and data for forwarded X11 and TCP connections).  The
         compression algorithm is the same used by gzip(1), and the
         “l(fā)evel” can be controlled by the CompressionLevel option for pro‐
         tocol version 1.  Compression is desirable on modem lines and
         other slow connections, but will only slow down things on fast
         networks.  The default value can be set on a host-by-host basis
         in the configuration files; see the Compression option.
 -4      Forces ssh to use IPv4 addresses only.
 -c cipher_spec
         Selects the cipher specification for encrypting the session.

         For protocol version 2, cipher_spec is a comma-separated list of
         ciphers listed in order of preference.  See the Ciphers keyword
         in ssh_config(5) for more information.

這里的要點(diǎn)是使用不同的加密密碼,在這種情況下,arcfour比默認(rèn)值更快,并壓縮正在傳輸?shù)臄?shù)據(jù)。

?


?

參考鏈接:

?

本文摘自 :https://www.cnblogs.com/

開通會(huì)員,享受整站包年服務(wù)立即開通 >