|

楼主 |
发表于 2006-6-18 11:11:08
|
显示全部楼层
以下转自
http://202.112.85.88/?p=51
vnc and vnc tunneling
在linux下的vnc这个软件包指代vncviewer
vncserver软件包指代vncserver
x11vnc软件包指代x11vnc
vncviewer是vnc的查看器
vncserver是在远程生成一个虚拟的vnc桌面服务
而x11vnc则是将已有的X11桌面通过vnc传送到远程,而不是使用虚拟的vnc服务,也就是说你在远程的桌面是可以通过vncviewer进行实际地控制,就像windows下的普通vnc服务一样
两个vnc服务都是非常有用的
下面讲讲用法:
vncviewer***********************************************
vncviewer hostip:1
vncviewer hostip::5900
这将开启一个vnc的客户端,hostip指开启vnc服务的远程系统的ip地址如192.168.212.128,
这儿如果使用X程序的编号(一般是:0 或:1等),那么中间应当用一个冒号
如果使用X程序的端口,一般是用::5900或::5901,中间用两个冒号,端口号是X程序的编号加上5900
vncserver***********************************************
vncserver :1 –geometry 800×600 –depth 24
vncserver后面有三个参数 :1,这是表示打开的程序编号,其开的对应端口号是5900+程序编号,这个数值可以看$HOME/.vnc/目录的log文件,里面记录非常详细
–geometry 800×600 表示打开的虚拟窗口的分辨率是800×600,也可以是1024×768,或者是640×480,或者是940×705,一般要求长宽比是4:3
–depth 24 表示的是色彩深度是24位的,也可以是16和15以及8
x11vnc***********************************************
x11vnc的用法不是打开虚拟的vnc服务,而是把当前已经打开的X桌面通过vnc的形式发布出来,使远程可是直接控制真实的X桌面。
其用法是在已经打开X桌面的远程系统上,运行一个shell,打入如下命令
x11vnc –auth $HOME/.Xauthority –display :0 –forever –shared –rfbauth $HOME/.vnc/x11passwd
这样在远程用命令来打开远程服务 vncviewer hostip::5900
其中–forever的作用是让你在关闭远程的vncviewer之后不关闭x11vnc的服务
–shared的作用是让多个vncviewer同时登录
–viewonly的作用是使vncviewer对真实的X桌面无法操作
–rfbauth $HOME/.vnc/x11passwd是启用保存在$HOME/.vnc/x11passwd里面的密码
x11vnc的主页是 http://www.karlrunge.com/x11vnc/
如果打开x11vnc成功,会有如下的显示
When x11vnc starts up there will then be much chatter printed out, until it finally says something like:
.
.
13/05/2004 14:59:54 Autoprobing selected port 5900
13/05/2004 14:59:54 screen setup finished.
13/05/2004 14:59:54
13/05/2004 14:59:54 The VNC desktop is far-away:0
PORT=5900
x11vnc的关闭使用,其中 -R参数有很多参数值,可以参看man x11vnc
>x11vnc -r stop
x11vnc的密码生成方法是
>x11vnc -storepasswd zzzz $HOME/.vnc/x11passwd
这句话将密码zzzz保存在文件 $HOME/.vnc/x11passwd里面,使用密码文件见上
当然密码和文件都是由你自己指定了
vnc的安全性问题*******************************
vnc的安全性在于结合ssh,分客户端为windows和linux的情况
在 linux下面的用法是
在窗口一的shell里面用下述命令登录远程机器
>ssh -L localhost:5905:192.168.212.128:5900 guest@192.168.212.128
ssh -L 本地名称:本地端口:远程ip:远程端口 远程登录帐号
在另一个窗口的shell里用下面的命令登录vnc
> vncviewer –encodings "copyrect tight zrle hextile" localhost:0
Note: The -encodings option is very important: vncviewer will default to "raw" encoding if it thinks the connection is to the local machine, and so vncviewer gets tricked this way by the ssh redirection. "raw" encoding will be extremely slow over a networked link, so you need to force the issue with -encodings "copyrect tight …".
Note that "x11vnc -localhost …" limits incoming vncviewer connections to only those from the same machine. This is very natural for ssh tunneling (the redirection appears to come from the same machine). Use of a VNC password is also strongly recommended.
在windows下面,用putty做ssh tunneling是最好也最方便的事
VNC through SSH Tunneling with PuTTY
by Andrew E. Santosa, 29 April 2003
The principle of SSH tunneling here is to create a virtual server at the Windows machine side (localhost). Connections to the port are forwarded by PuTTY to a remote host, i.e., every client that connects to that port at the localhost will actually be talking to the remote host.
After starting PuTTY, at the PuTTY Configuration window select Tunnels: in the Category: box. Then in the Source port box enter 5901 (or any number you like, but 5901 is probably a safe port number not being used by any other networking program at your Windows machine). In the Destination box enter your remote server name and the remote server’s port separated by semicolon. As shown in the example below, it is otah.comp.nus.edu.sg:5901. The remote server’s port cannot be arbitrary. Display i of VNC server actually accepts connections through port 5900 + i. So if we want to connect to display 1 of the VNC server as in this example, we need to connect to port 5901 of the remote server.
Make sure that the Local radio button is being selected, then click the Add button. The line L5901 remote.host.name:5901 should appear in the Forwarded ports box.
Then click Section in the Category: box, enter your remote host name (otah.comp.nus.edu.sg in this example), select SSH for the protocol. Then name your connection by entering a string in the Saved Sessions input box. In the following picture we entered Otah VNC Display 1.
Then click the Save button, the string entered will appear in Saved Sessions list. It is possible not to save the session, but it is more practical for repeated use of the tunneling.
Double click on the session name in the Saved Sessions list to start connecting to the remote host. A terminal window will appear. Enter your login name and password of your account at the remote host. The next time you start PuTTY you can proceed from this step without reconfiguring.
Start your VNC server when you have not done so already, and when asked for password, enter an appropriate one.
Now you can start the VNC viewer at your Windows host. When you start your VNC server, a Connection Details dialog box will appear. Enter localhost::5901 as the VNC server, and click OK.
A password dialog box will appear,
and after entering your password you can access the VNC display.
vnc2swf**********************************************
vnc2swf的作用是把
1.所登录的远程的vnc上的操作全部记录为swf动画,
2.或者把本地的vnc服务的记录为动画
第一种作法的命令如下
vnc2swf -shared zzz.swf 192.168.212.128::5905 -startrecording
这个命令实际上就是打开一个vnc的客户端登录远程桌面,并将所有的操作记录成zzz.swf
这是非常完美的用法,我想对我已经足够,同时在你的客户端的左上角有一个recording的字符
第二种方法我不想用了,不想去深究了
vnc中使用X程序*******************************
vmware以及其他X程序在vnc中的使用
如果你开启了一个vncserver的服务(xvnc),而且你是开启xvnc服务的用户,在其中的shell下可以直接开启X程序服务。
但是如果你用su命令在shell下进入其他用户,并在shell下开启其他用户的X程序,那么你在开启vnc服务的用户名下的shell中使用 xhost + 127.0.0.1 这个命令,以使得vnc服务显示该X程序。
如果你使用vmware,你使用一次xhost + 127.0.0.1 是不够的,你会发现vmware无法显示虚拟机的VGA内容。实际上如果你连续使用两次xhost + 127.0.0.1,就可以了,这实在是太矬了。 |
|