分页: 1 / 1

[分享]用ssh加密vnc通信

发表于 : 2007-03-30 19:15
aloha
远程桌面有两种,一种是通过XDMCP,另一种是通过VNC的远程桌面,两者的区别是
XDMCP登录是新开了一个session,退出登录后这个session就关闭了。
VNC是运行当前的session,退出后原session继续,比较适合在一台机器上长时间运行一个有图形界面的程序,而且需要中间通过图形登录上去查看,比如我在办公室的机器上一直运行着email的图形客户端,回家后想上去看看有什么新的email。

vnc协议缺省是TCP 5900,文本传输,没有任何保密性可言,我们可以把SSH和VNC结合起来,提高VNC的保密性。下面假定远端和本地都运行ubuntu。

远端:

首先打开vnc server,ubuntu缺省安装的是vino-server, system-> preferences -> remote desktop,钩上Allow other users to view your desktop就立刻打开了vino server,把ask for confirmation的钩去掉。如果愿意,也可以设置密码保护。
到现在,可以通过本地的xvncviwer访问远端,当然没有任何保密性。
apt-get install openssh-server,安装ssh服务器,在本地通过ssh访问远端测试是否安装成功
ssh remote-server -l user
通过防火墙,将5900端口关闭,一定要把ssh端口打开,缺省是tcp 22。
到此为至,远端已经设置完毕,通过xvncviewer已经不能访问远端了。

本地:

缺省已经安装了xvncviewer,如果没有则安装之。
打开两个窗口,
首先在第一个窗口运行
ssh -L 5900:localhost:5900 user@remote-server
如果能够登录,则在第二个窗口运行
xvncviewer localhost

发表于 : 2007-03-31 1:31
eexpress
不错。只是这不是嵌套的方式,而是一个管理另外一个的方式了。还是强制拦截管理。呵呵。强盗。不过是lin的通常方式。

发表于 : 2007-03-31 4:08
laborer
我一直都是这么用的,不错。

发表于 : 2007-03-31 21:13
aloha
其实这个原理也可以用于其他的没有加密的服务,好像XDMCP也是不加密的。
对SSH也是有要求的,就是要V2版本的。

发表于 : 2007-06-18 0:16
zxm
不太理解,为什么最后是: xvncviewer localhost ?
难道要登录的不是 remotehost 么?

发表于 : 2007-06-18 20:24
czybear
就是建了个ssh tunnel吧

发表于 : 2007-06-19 23:18
zxm
可是按照上面一路做下来,最后登录的还是本地系统 :(

发表于 : 2007-06-20 7:10
aloha
一定要ssh成功后,再进行vncviewer localhost. ssh -L的作用就是把某个本地端口和远端绑定并转发过去。

-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be
forwarded to the given host and port on the remote side. This
works by allocating a socket to listen to port on the local side,
optionally bound to the specified bind_address. Whenever a con‐
nection is made to this port, the connection is forwarded over
the secure channel, and a connection is made to host port
hostport from the remote machine. Port forwardings can also be
specified in the configuration file. IPv6 addresses can be spec‐
ified with an alternative syntax:
[bind_address/]port/host/hostport or by enclosing the address in
square brackets. Only the superuser can forward privileged
ports. By default, the local port is bound in accordance with
the GatewayPorts setting. However, an explicit bind_address may
be used to bind the connection to a specific address. The
bind_address of “localhost” indicates that the listening port be
bound for local use only, while an empty address or ‘*’ indicates
that the port should be available from all interfaces.

发表于 : 2007-06-24 12:36
冲浪板
zxm 写了:可是按照上面一路做下来,最后登录的还是本地系统 :(
zxm 写了:可是按照上面一路做下来,最后登录的还是本地系统 :(
你没明白,去看ssh(openssh)的文章...

btw:LZ HD啊,要说就说清楚嘛,另外给介绍一下ssh文章的地址-如果你懒得自己说。

而且,我用-L 5900:localhost:5900 就没成过,非要-L 5900:remote_machine:5900才成....

发表于 : 2008-01-24 13:27
xautofzx
确实是先用
ssh -L 5900:RemoteServer:5900 user@RemoteServer
这样就会建立加密隧道,把远程服务器的5900端口映射到本机的5900端口。

然后在本机运行 vncviewer localhost
就会连接本机的映射端口,然后通过加密隧道到达远程主机,再转发给远程的5900端口。

注意:本机如果也启用了“远程桌面”,则5900端口被占用,换一个空闲的即可。

用此法能否实现多用户远程桌面?

发表于 : 2008-01-28 11:46
zw88168
用此法能否实现多用户远程桌面?

发表于 : 2008-01-28 20:22
xautofzx
不行,这只能是当前登录的桌面,要多用户就得用XDMCP

http://wiki.ubuntu.org.cn/index.php?tit ... B.E5.BD.95

通过XDMCP 远程登录

发表于 : 2008-07-18 15:49
spiritfrog
xautofzx 写了:不行,这只能是当前登录的桌面,要多用户就得用XDMCP

http://wiki.ubuntu.org.cn/index.php?tit ... B.E5.BD.95

通过XDMCP 远程登录
也不是的了, vnc可以支持多用户登录,多session的。只不过你用的是ubuntu自带的,只能单session了。