Windows利用SSH - X遠程登錄Linux主機(X11-forwarding)


 

pediawiki對X11的定義如下:

The X window system (commonly X Window System or X11, based on its current major version being 11) is a computer software system and network protocol that provides a basis for graphical user interfaces (GUIs) and rich input device capability for networked computers. It creates a hardware abstraction layer where software is written to use a generalized set of commands, allowing for device independence and reuse of programs on any computer that implements X. ... Each person using a networked terminal has the ability to interact with the display with any type of user input device. Due to the ubiquity of support for X software on Unix, Linux and Mac OS X, X is commonly used to run client applications on personal computers even when there is no need for time-sharing.【http://en.wikipedia.org/wiki/X11

即:X11是X Window System主版本11的縮寫,它不光是一個基本的GUI軟件,X11也被定義為一個網絡協議,因為X11提供了非常靈活的網絡訪問接口。

 

 

 

通過SSH 的 X11 forwarding訪問X11方便又安全

什么是 X11 forwarding?

X forwarding是X的一個功能,它可以讓程序運行在一台主機上,而用戶在另外一台機器上與之交互。其概念上與VNC和微軟的遠程桌面類似,而與這些軟件不同,我們想要實現的是在Microsoft Windows平台運行特定的圖形用戶界面程序,而不是顯示控制整個桌面。在X上下文中,客戶端“client”是指運行程序的主機,而你坐在服務器“Server”前面,這點和常規的叫法不同。舉例來說,你通過A遠程打開B上面的程序,也就是說你在操作A,而你要遠程控制B,那么B就是客戶端,A是服務端。

Think of it this way: the X server is serving you, the human being, to the programs on the remote computer. The client, a program, makes requests of you through the X server by changing its graphical display, and you respond to it by clicking on it or typing into it.

SSH 的 X11 forwarding 特性可以使 X client 和 X server 安全地通訊。使用 X11 forwarding 后,從 X client 到 X Server 方向的數據先被送至 SSH server,SSH server 利用和 SSH client 的安全通道轉發給 SSH client,再由 SSH client 轉發給 X server,從 X server 到 X client 的數據流同理。這里 SSH server 和 SSH client 充當了 X client 和 X server 間數據的轉發器,由於 SSH server 和 X client、SSH client 和 X server 一般在同一台機器上,它們之間是一種安全的進程間通訊,而 SSH server 和 SSH client 間的通訊也是安全的,所以 X client 和 X server 間的通訊就是安全的。

 

需要哪些工具?

我們在Microsoft Windows平台通過SSH訪問X11,參考上圖所示,那么我們就需要:

1) SSH客戶端 - 這里我們使用putty

    下載地址:http://www.chiark.greenend.org.uk/~sgtatham/putty/

2)X Server端 - 我們使用標准X.Org X server的Windows移植版本Xming

Xming的介紹見:http://www.straightrunning.com/XmingNotes/

 

點擊下載下面地址頁面里的xming里面的exe文件下載(建議下載最近版)

http://sourceforge.net/projects/xming/files/

注意這里面有兩個xming和xming-mesa,前者用OpenGL展示界面,后者用Mesa展示界面,對於一般用戶差別不大,任選一個即可

 

3)   字體庫:

 

點擊下載下面地址頁面里的xming-fonts里面的字體庫exe文件下載(建議下載最近版)

http://sourceforge.net/projects/xming/files/

 

以上應用程序共putty免安裝,后面兩個是安裝包,直接點擊默認安裝。 

 

運行

運行XMing后系統右下角托盤里(任務欄)多了X字樣的圖標,鼠標放在上面會有類似“Xming server - 0:0”的字樣。

運行putty,在host name里面填寫你的目標IP地址,例如“192.168.2.225”。在putty界面的左邊點擊Connection/SSH/X11 子菜單。選中"Enable X11 Forwarding", 在 "X display location"中輸入 "localhost:0:0" 。注意這里的數字應該和鼠標移到系統托盤里顯示出來的數字一致(上面紅色字體),如果是“Xming server - x:y”那么這里應該是“localhost x:y”。 保持單選框"MIT-Magic-Cookie-1"不變。

點擊左邊“Session”按鈕,輸入名字“MyPC”點擊“Saved Sessions”保存設置。然后雙擊打開終端,輸入用戶名和密碼,運行gedit或者gnome-terminal試試。:-)

 

還有其他實現windows下訪問X11 forwarding的方案,例如

Cygwin/X - http://x.cygwin.com/

WeirdX - http://www.jcraft.com/weirdx/index.html

 

 

參考:

http://courses.cms.caltech.edu/cs11/misc/xwindows.html

http://hi.baidu.com/edeed/blog/item/4f47738d98891e1ab21bba2f.html

http://oss.org.cn/ossdocs/gnu/gtk+_FAQ/GTK+_FAQ.htm


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM