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

  • 10
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值