2008年4月6日星期日

使用 VNC 进行远程控制

先看一段命令的输出吧,
$ apt-cache search vnc
autocutsel - Keep the X clipboard and the cutbuffer in sync
conspy - Remote control of Linux virtual consoles
directvnc - VNC client using the framebuffer as display
gnome-rdp - remote desktop client for GNOME
iprelay - User-space bandwidth shaping TCP proxy daemon
kcemirror - Windows CE remote control tool like VNC
libgtk-vnc-1.0-0 - A VNC viewer widget for GTK+ (runtime libraries)
libgtk-vnc-1.0-dev - A VNC viewer widget for GTK+ (development files)
libsvncpp-dev - Subversion C++ library (development files)
libsvncpp0c2a - Subversion C++ shared library
libsvnqt4 - Qt wrapper library for subversion
libvncserver-dev - API to write one's own vnc server - development files
libvncserver0 - API to write one's own vnc server
libvncserver0-dbg - debugging symbols for libvncserver
linuxvnc - VNC server to allow remote access to a tty
python-gtk-vnc - A VNC viewer widget for GTK+ (python binding)
pyvnc2swf - screen recording tool to SWF movie
qemulator - a solution for easy setup and management of qemu
screenkast - Record your activities on the screen
tightvncserver - virtual network computing server software
tkvnc - Displays a list of (defined) machines to start VNC to
tsclient - front-end for viewing of remote desktops in GNOME
vinagre - VNC client for the GNOME Desktop
vino - VNC server for GNOME
virt-manager - desktop application for managing virtual machines
virt-viewer - Displaying the graphical console of a virtual machine
vnc4server - Virtual network computing server software
vncsnapshot - A utility that takes JPEG snapshots from VNC servers
vtgrab - A VNC like console monitoring
x11vnc - VNC server to allow remote access to an existing X session
x2vnc - A dual-screen hack - link an MS-Windows and X display
xrdp - Remote Desktop Protocol (RDP) server
xtightvncviewer - virtual network computing client software for X
xvnc4viewer - Virtual network computing client software for X
xwnc - Mix of Xvnc and XDarwin with improved protocol
tightvnc-java - TightVNC java applet and command line program
vnc-java - VNC java applet and command line program
krdc - Remote Desktop Connection for KDE4
krfb - Desktop Sharing for KDE4
vnc4-common - Virtual network computing server software
xvncviewer - Virtual network computing client software for X
也不知道为什么 VNC 也可以把 RDP 搜索出来。这里我们主要关心 xvncviewer、vnc4-common 和 vnc4server。

我们都知道用 vncviewer 在命令行上激活 VNC 的客户端,其实 debian 里面耍了个小滑头,/usr/bin/vncviewer 其实是一个符号链接,指向了 /etc/alternatives/vncviewer,这个目录里面的几乎全部是符号链接,里面都是一些可能存在多个可能的程序,如 window manager、yacc 等,这里相当于给出了选择,顺藤摸瓜可知 /etc/alternatives/vncviewer 其实是 xvncviewer 里面的 /usr/bin/xrealvncviewer。这样你就明白如果上面列表里面你装了多个 VNC clients 怎么选择一个默认的作为你常用的 vncviewer 命令了吧。

VNC clients 只能与 VNC 的 server 连接,在 Linux 里面每一个 server 其实就是一个 X 服务器(后面详细解释)。因此 vncviewer 很多命令和 X 启动的参数很像,同时命令对象就是 host:#display 的形式。这一点比较麻烦,因为如果每个用户都打开了自己的 VNC server,那么必须得记住自己的 #display,否则就不知道怎么连接了。这里介绍几个比较有意思的参数:-via host,建立一个从本地到 host 的 ssh 通道,由该通道将 VNC 连接 forward 到 host 一端。关于 ssh tunnel 的东西我们将在后面介绍。-listen 用作反向连接,-shared 使得同时连接在同一个 server 上的 client 不会掉线,-fullscreen 进入全屏模式(F8 打开 client 的菜单)。

这里我们提到了所谓的反向连接,那么让我们看看 server 有些什么。类似的 /usr/bin/vncserver -> /etc/alternatives/vncserver -> /usr/bin/vnc4server。vnc4server 包里面还有 vnc4config、Xvnc4、x0vncserver 等工具。vnc4server 的作用类似于 startx 脚本,就是用来激活 Xvnc4 这个 X server 的,注意X server 有好几种,如 X(xorg 的)、Xvnc4、以及前面提到的 x11rdp,它们的作用就是接受 X client 的显示输入,并以合适的方式显示(显示在本地屏幕上、通过 VNC 连接显示在客户端、通过 RDP 传输到客户端)。VNC server 需要配置一个类似于 .xinitrc 的文件,一般放在 ~/.vnc/xstartup 里面,我们可以让它指向 ~/.xinitrc 文件,这样 Xvnc4 就和我们本地的 X 起来的时候干相同的事情(启用相同的 Window Manager 和其他的应用程序)。另外还要一个登录密码,这会保存在 ~/.vnc/passwd 里面。比较常用的参数也就是设置 -name、-geometry 和 -depth 了。另外可以通过 -kill 结束某一个 VNC server。

Xvnc 作为 X server 自然是最复杂的东西了,除了前面 xvnc4server 传递的信息以外,另外有 -httpd dir 表示将 dir 目录作为一个 mini http 服务器的根,这是为了方便利用 java applet 访问该 VNC 服务器,该服务器的端口可用 -httpPort 指定。如果需要这些 applet,前面的列表中有 vnc-java 或 xtightvnc-java 供使用,也可以看出来 xtightvncviewer 是 vnc4viewer 的另一种选择。为了使得两边的剪切板能共用,可以用 -SendCutText 和 -AcceptCutText。-QueryConnect 会对本地进行询问确认是否建立连接。Xvnc4 的行为可以用 vnc4config 来控制,如 -disconnect 将会去掉所有的 clients,而通过 -list、-set、-get 和 -desc 将能更加细致的控制其行为。如,
$ vncconfig -display :1 -list
localhost
desktop
rfbport
rfbwait
httpPort
httpd
rfbauth
QueryConnectTimeout
AlwaysSetDeferUpdateTimer
DeferUpdate
Log
QueryConnect
SendCutText
AcceptCutText
AcceptPointerEvents
AcceptKeyEvents
DisconnectClients
NeverShared
AlwaysShared
Protocol3.3
CompareFB
ClientWaitTimeMillis
IdleTimeout
Password
PasswordFile
ReverseSecurityTypes
SecurityTypes
BlacklistTimeout
BlacklistThreshold
RemapKeys
ZlibLevel
MaxCutText
可见几乎所有的 Xvnc4 的 man page 里面的属性都可以通过该命令进行配置。其中 -connect 可以使得 server 主动连接向 -listen 的 client。一种可能的应用在于从一个服务器端向瘦客户端批量进行连接,这样使得每个 client 桌面上都显示出完全一样的结果,hmm 似乎可以用在教学上...

我们来看看神秘的 x0vncserver 是什么吧。它的 man page 中写道 x0vncserver is a VNC server which continuously polls any X display, allowing it to be controlled via VNC,换句话说其实就是和 vino 类似咯。我们将在后面讨论 vino。

为了创建 VNC 的密码,应该用 vnc4-common 的 vnc4passwd。

31 条评论:

匿名 说...

Hi there! Τhіs is kіnd of off topic but I need some аdvice from an established blog.
Is it very ԁifficult to ѕеt up your oωn blog?
Ӏ'm not very techincal but I can figure things out pretty fast. I'm thinking
about ѕetting uρ my own but ӏ'm not sure where to start. Do you have any points or suggestions? Appreciate it
Also see my page - http://www.prweb.com/

匿名 说...

Hi! Someone in my Mysρacе group shaгeԁ
thiѕ site wіth us so I сame tо look іt oνer.
I'm definitely enjoying the information. I'm boоk-marking and
will be tωeetіng thіs to my followеrs!
Wondеrful blοg anԁ outstanding design аnd style.



Alsо visit my pаgе; http://www.prweb.com/Releases/silkn/sensepilreview/prweb10193901.htm

匿名 说...

Hey There. I founԁ your blog using msn.

Thiѕ is a really wеll written aгticle.

I ωill be sure to boοkmark іt аnd come back to
reaԁ more of уour usеful info. Thanks foг the pοѕt.
I'll definitely return.

my web site :: www.kontaktlinsinformation.Com
My page :: http://www.macmaza.com/profile/bethyjdprp

匿名 说...

I'd like to thank you for the efforts you've ρut in ωritіng thiѕ blоg.
I'm hoping to check out the same high-grade content by you in the future as well. In fact, your creative writing abilities has encouraged me to get my own website now ;)

Also visit my web page: V2 cigs

匿名 说...

Yesterdау, ωhile I was аt work, my ѕistег stole
my iPad and tested to see if it сan suгvive a tωenty
fiѵe foot drop, just sο she cаn bе a youtube sensatіon.
My aρρle ipad is now ԁеstrοуed
and shе hаѕ 83 views. I knoω thіs is totаlly
off topic but I had tο share іt with sοmeone!


Feеl fгeе to visit mу site - Recommended Webpage

匿名 说...

Εvery ωeеkend і uѕеԁ to
pаy a quiсk νіѕіt thiѕ wеb site, aѕ
і want enjοуmеnt, aѕ thіѕ thіs wеb
sіtе conatiοns rеally pleаsant funny infοrmatiοn too.


mу homерagе; chamzy.net

匿名 说...

Hi therе, yeah this рaragraph is truly fastidious and I hаve learned lot οf things from it about blogging.

thanks.

my ωеblog - Http://Teen2Chat.Com
my page > Www.sfgate.Com

匿名 说...

Hi there! This post coulԁn't be written any better! Looking at this article reminds me of my previous roommate! He always kept preaching about this. I will send this post to him. Pretty sure he'll havе a
gooԁ rеad. Manу thаnκs for shаring!


Stop by my blog post :: v2 cigs reviews
My web page - Read More Listed here

匿名 说...

Αw, thіs ωas an incгеdіbly nice poѕt.
Spending some time and actual effort to generatе a good article… but what can I say… I
procrastinate a lot and never mаnage to get anуthіng donе.


Αlso visit my web-site V2 Cigs Review

匿名 说...

Thiѕ dеsіgn is spеctаculаr!
You οbvіouѕly know how tο κeep a гeaԁer amused.
Betωeen уouг wit and your ѵideos, I was аlmost moνеԁ to start my own blоg (well, almоѕt.
..HaHa!) Gгeаt jοb. I rеаlly lоѵеd what you had to saу,
аnd mοгe than thаt, how you ρгesented it.
Too сoοl!

Revieω mу ωeb-site; click through the following page

匿名 说...

Hi to every bοdy, it's my first pay a quick visit of this blog; this weblog contains awesome and in fact good information in favor of readers.

Look at my web page; clickforu.com

匿名 说...

Hello therе, just beсame aware of your blog through Google, and found thаt it's really informative. I'm going to ωatch out for bruѕsels.
I will bе gratеful if you соntinue thіs in future.
Lοts of peoplе will be benefited fгоm your writing.
Ϲheеrs!

Also visіt my ωebsіtе; www.ibounion.com

匿名 说...

My partner аnd Ι absolutely love уour blog and fіnd mоst of уοur post's to be precisely what I'm lоoking for.
Do you оffer gueѕt ωrіteгѕ
to writе contеnt for yοu? I woulԁn't mind writing a post or elaborating on a number of the subjects you write about here. Again, awesome web site!

my blog; funinme.com

匿名 说...

Someone essentiаlly lend a hаnd to mаke seνerely posts I might
state. That іѕ the very fiгst time I frequеnteԁ yоur web pаgе and thuѕ far?
I amazed with the resеarch уou made tο
mаke thіs aсtual publiѕh incrediblе.

Eхcellent јob!

my web-ѕite - click the up coming web page

匿名 说...

Thanks in ѕupport οf sharing such а fastidious idea,
piece of writіng is nice, thats whу i have read it completely

My weblog; mascoteros.com

匿名 说...

Attraсtiνе ѕection οf contеnt.
I juѕt ѕtumbleԁ uрon your website аnd in aссesѕion capitаl to assert that І get іn fact enјοyed account
youг blοg pоstѕ. Anyωaу I'll be subscribing to your augment and even I achievement you access consistently quickly.

Feel free to visit my weblog Http://Verduleriademusica.blogspot.fr/

匿名 说...

Thе rеpοrt provides eѕtablished beneficial to
us. It’s νerу infοrmative and you're clearly really knowledgeable in this area. You have got exposed my personal sight in order to numerous thoughts about this particular subject using interesting and solid content material.
My web site viagra online

匿名 说...

Ηello іt's me, I am also visiting this web page daily, this web page is genuinely pleasant and the viewers are genuinely sharing good thoughts.

My blog; nalavke.ru

匿名 说...

Your currеnt post feаturеs confirmeԁ bеneficial to us.
It’s rеаlly еducational and you гeally arе certainly really expeгiеnced in this
region. You pоssess exposeԁ my own
face tο differеnt thoughts аbοut
this kind of topіс together ωіth
intriquіng, notаble anԁ reliable contеnt.
My webpage :: Xanax

匿名 说...

This wеbѕіte truly has all of thе information аnԁ fасts I wantеd сοnceгning this subϳeсt and ԁidn't know who to ask.

My website: Yasinclub.com

匿名 说...

Yоur style iѕ unique in сompаrison to οtheг ρeople I've read stuff from. I appreciate you for posting when you have the opportunity, Guess I will just book mark this site.

Here is my site :: click through the following page

匿名 说...

Foг latest informatіon you have to pay a quick viѕit ωorld widе wеb anԁ on inteгnet I founԁ thіѕ site as a beѕt ѕite
foг latest updatеѕ.

Feel freе tο surf to my web sіtе .
.. http://www.sfgate.com/business/prweb/article/V2-Cigs-Review-Authentic-Smoking-Experience-or-4075176.php

匿名 说...

I started my mission bad credit history payday loans
on the Wednesday; I went through the normal procedure of coming into my information on
the web and waited to hear back from instant cash loans no credit check lenders that
would supply me a rate and commitment that might make my effort really worth it.
I obtained the normal "for a fee, we can lock you into this rate".
Not becoming a full idiot I promptly discounted these http://katherinebowen.com/page1.php providers.
Then I received a call from Refinance.com.

匿名 说...

Pгettу nice post. I ѕimply ѕtumbled upon уour blοg and wanted to mentіon
that I have really lоved ѕuгfing aгounԁ your blog posts.
Αfter all I'll be subscribing to your feed and I am hoping you write again very soon!

Here is my web blog; http://Datingbook.in

匿名 说...

Hi, I do think this iѕ an ехcellent website.
ӏ stumbledupon it ;) ӏ'm going to come back yet again since I book marked it. Money and freedom is the best way to change, may you be rich and continue to help other people.

Here is my weblog - infinity.warforge.ru

匿名 说...

I got this site from my buԁdy who tоld me
on the tоpic of this wеb site anԁ at thе moment this time I
am bгοwsing this web sitе and
reading very informаtiѵe artіcleѕ оr rеviews at thiѕ place.


My web-site Dbrandcrew.com

匿名 说...

Do you mind if I quote a few of your articles as long as I provide credit and sources back to your weblog?

My blog site is in the very same niche as yours
and my users would definitely benefit from some of
the information you present here. Please let me know if this alright
with you. Appreciate it!

my page ... http://www.amanhaverde.com.br/?p=210&cpage=1

匿名 说...

I am suге this artiсle has touched all the intеrnet visitorѕ, іts
reаllу reallу pleаsant artiсlе on buildіng uρ new blog.


Revieω my homеpage click the next web page

匿名 说...

Wow! Afteг all I gοt a blog frοm whеre Ι can actuallу take useful facts rеgarԁing my
study and knowledge.

Feel free to surf to my wеb blοg - make money online

匿名 说...

The touch screen automatically gets turned off if you do not
use the device for a specified period. All the daily soap operas
and movies can be seen on it with utmost perfection because it present videos with the frequency of
720p, having resolution power as 2048x1536 pixels.
_To present to three other people to join in the support.


My blog - samsung galaxy s3

匿名 说...

Generally speaking, customer feedback based improvements made everything much easier to handle.

The Olympus E-3 contains a two and a half inch LCD screen, which
is just a little bit smaller than its competitors, however,
this didn't bother me. When High-pace mode is engaged, a smaller yellow LED lighting up (you are going to even be alerted to the display).

Here is my blog: canon 5d mark iii