2011年3月30日 星期三

NOTE:About VNC

How to setup vnc on Ubuntu system??

setup command

mad@mad-desktop:~$ sudo apt-get install x11vnc vnc-common


vnc server start
we can use the parameter of x11vnc like passwd、rfbport....

mad@mad-desktop:~$ x11vnc -passwd xxxxxx -rfbport 5999


then we can see some information of x11vnc server on the terminal.

30/03/2011 22:46:01 passing arg to libvncserver: -passwd
30/03/2011 22:46:01 passing arg to libvncserver: -rfbport
30/03/2011 22:46:01 passing arg to libvncserver: 5999
30/03/2011 22:46:01 x11vnc version: 0.9.3 lastmod: 2007-09-30
30/03/2011 22:46:01
30/03/2011 22:46:01 *** XOpenDisplay failed. No -display or DISPLAY.
30/03/2011 22:46:01 *** Trying ":0" in 4 seconds. Press Ctrl-C to abort.
30/03/2011 22:46:01 *** 1 2 3 4
30/03/2011 22:46:05 *** XOpenDisplay of ":0" successful.
30/03/2011 22:46:05
30/03/2011 22:46:05 Using X display :0
30/03/2011 22:46:05
30/03/2011 22:46:05 ------------------ USEFUL INFORMATION ------------------
30/03/2011 22:46:05 X DAMAGE available on display, using it for polling hints.
30/03/2011 22:46:05 To disable this behavior use: '-noxdamage'
30/03/2011 22:46:05
30/03/2011 22:46:05 Wireframing: -wireframe mode is in effect for window moves.
30/03/2011 22:46:05 If this yields undesired behavior (poor response, painting
30/03/2011 22:46:05 errors, etc) it may be disabled:
30/03/2011 22:46:05 - use '-nowf' to disable wireframing completely.
30/03/2011 22:46:05 - use '-nowcr' to disable the Copy Rectangle after the
30/03/2011 22:46:05 moved window is released in the new position.
30/03/2011 22:46:05 Also see the -help entry for tuning parameters.
30/03/2011 22:46:05 You can press 3 Alt_L's (Left "Alt" key) in a row to
30/03/2011 22:46:05 repaint the screen, also see the -fixscreen option for
30/03/2011 22:46:05 periodic repaints.
30/03/2011 22:46:05
30/03/2011 22:46:05 XFIXES available on display, resetting cursor mode
30/03/2011 22:46:05 to: '-cursor most'.
30/03/2011 22:46:05 to disable this behavior use: '-cursor arrow'
30/03/2011 22:46:05 or '-noxfixes'.
30/03/2011 22:46:05 using XFIXES for cursor drawing.
30/03/2011 22:46:05 GrabServer control via XTEST.
30/03/2011 22:46:05
30/03/2011 22:46:05 Scroll Detection: -scrollcopyrect mode is in effect to
30/03/2011 22:46:05 use RECORD extension to try to detect scrolling windows
30/03/2011 22:46:05 (induced by either user keystroke or mouse input).
30/03/2011 22:46:05 If this yields undesired behavior (poor response, painting
30/03/2011 22:46:05 errors, etc) it may be disabled via: '-noscr'
30/03/2011 22:46:05 Also see the -help entry for tuning parameters.
30/03/2011 22:46:05 You can press 3 Alt_L's (Left "Alt" key) in a row to
30/03/2011 22:46:05 repaint the screen, also see the -fixscreen option for
30/03/2011 22:46:05 periodic repaints.
30/03/2011 22:46:05
30/03/2011 22:46:05 XKEYBOARD: number of keysyms per keycode 6 is greater
30/03/2011 22:46:05 than 4 and 290 keysyms are mapped above 4.
30/03/2011 22:46:05 Automatically switching to -xkb mode.
30/03/2011 22:46:05 If this makes the key mapping worse you can
30/03/2011 22:46:05 disable it with the "-noxkb" option.
30/03/2011 22:46:05 Also, remember "-remap DEAD" for accenting characters.
30/03/2011 22:46:05 X FBPM extension not supported.
30/03/2011 22:46:05 X display is capable of DPMS.
30/03/2011 22:46:05 --------------------------------------------------------
30/03/2011 22:46:05
30/03/2011 22:46:05 Default visual ID: 0x21
30/03/2011 22:46:05 Read initial data from X display into framebuffer.
30/03/2011 22:46:05 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/4608
30/03/2011 22:46:05
30/03/2011 22:46:05 X display :0.0 is 32bpp depth=24 true color
30/03/2011 22:46:05
30/03/2011 22:46:05 Listening for VNC connections on TCP port 5999
30/03/2011 22:46:05
30/03/2011 22:46:05 Xinerama is present and active (e.g. multi-head).
30/03/2011 22:46:05 Xinerama: enabling -xwarppointer mode to try to correct
30/03/2011 22:46:05 Xinerama: mouse pointer motion. XTEST+XINERAMA bug.
30/03/2011 22:46:05 Xinerama: Use -noxwarppointer to force XTEST.
30/03/2011 22:46:05 fb read rate: 37 MB/sec
30/03/2011 22:46:05 screen setup finished.
30/03/2011 22:46:05

The VNC desktop is: mad-desktop:99
PORT=5999

******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?

The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval. It should work with any VNC viewer. Try it by running:

x11vnc -ncache 10 ...

more info: http://www.karlrunge.com/x11vnc/#faq-client-caching



now we can use vncviewer to remote the desktop.



vnc server will show some information on the terminal

30/03/2011 22:49:44 Got connection from client xxx.xxx.xxx.xxx
30/03/2011 22:49:44 other clients:
30/03/2011 22:49:49 Disabled X server key autorepeat.
30/03/2011 22:49:49 to force back on run: 'xset r on' (3 times)
30/03/2011 22:49:49 created xdamage object: 0x1600028
30/03/2011 22:49:49 Client Protocol Version 3.3
30/03/2011 22:49:49 Protocol version sent 3.3, using 3.3


then we login the vnc server,the terminal show some information as below

30/03/2011 22:50:06 cutbuffer_send: no send: uninitialized clients
30/03/2011 22:50:54 Pixel format for client xxx.xxx.xxx.xxx:
30/03/2011 22:50:54 8 bpp, depth 8
30/03/2011 22:50:54 true colour: max r 7 g 7 b 3, shift r 0 g 3 b 6
30/03/2011 22:50:54 Using ZRLE encoding for client xxx.xxx.xxx.xxx
30/03/2011 22:50:54 Pixel format for client xxx.xxx.xxx.xxx:
30/03/2011 22:50:54 32 bpp, depth 24, little endian
30/03/2011 22:50:54 true colour: max r 255 g 255 b 255, shift r 16 g 8 b 0
30/03/2011 22:50:54 no translation needed
30/03/2011 22:50:55 Switching from ZRLE to hextile Encoding for client xxx.xxx.xxx.xxx


we turn off vnc viewer, the vnc server will show below

30/03/2011 23:00:55 client_count: 0
30/03/2011 23:00:55 Restored X server key autorepeat to: 1
30/03/2011 23:00:55 viewer exited.
30/03/2011 23:00:55 deleted 36 tile_row polling images.
mad@mad-desktop:~$


In addition, we can use xinetd that is network management service to manage x11vnc

setup xinetd

mad@mad-desktop:~$ sudo apt-get install xinetd


The xinetd can namage service that be located in /etc/xinetd.d/
Now, we add x11vnc service to xinetd

mad@mad-desktop:~$ vim /etc/xinetd.d/x11vnc


Write down some code like below

service x11vnc
{
port = 5900
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/x11vnc
server_args = -inetd -o /var/log/x11vnc.log -display :0 -auth /var/lib/gdm/:0.Xauth -many -bg -rfbauth /etc/x11vnc.pass
disable = no
}


We can use add passwd to x11vnc

mad@mad-desktop:~$ sudo x11vnc -storepasswd XXXXXX /etc/x11vnc.pass
stored passwd in file /etc/x11vnc.pass


Now use vnc viewer to remote the desktop

NOTE:
If you want to know what port have be used
you can use netstat command to search what service is using the port.

mad@mad-desktop:~$ netstat -anp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:33739 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:49200 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:1337 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:38076 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:51678 0.0.0.0:* LISTEN -
tcp 0 232 140.116.226.214:22 140.116.226.224:1559 ESTABLISHED -
tcp6 0 0 :::5901 :::* LISTEN 3835/vino-server
tcp6 0 0 :::8080 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp 0 0 100.101.101.3:137 0.0.0.0:* -
udp 0 0 140.116.226.214:137 0.0.0.0:* -
udp 0 0 192.168.0.214:137 0.0.0.0:* -
udp 0 0 0.0.0.0:137 0.0.0.0:* -
udp 0 0 100.101.101.3:138 0.0.0.0:* -
udp 0 0 140.116.226.214:138 0.0.0.0:* -
udp 0 0 192.168.0.214:138 0.0.0.0:* -
udp 0 0 0.0.0.0:138 0.0.0.0:* -
udp 0 0 0.0.0.0:778 0.0.0.0:* -
udp 0 0 0.0.0.0:53008 0.0.0.0:* -
udp 0 0 0.0.0.0:49938 0.0.0.0:* -
udp 0 0 0.0.0.0:59815 0.0.0.0:* -
udp 0 0 0.0.0.0:69 0.0.0.0:* -
udp 0 0 127.0.0.1:59213 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 0.0.0.0:1900 0.0.0.0:* -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:53618 0.0.0.0:* -
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 8450 - /tmp/.X11-unix/X0
unix 2 [ ACC ] STREAM LISTENING 7596 - @/var/run/hald/dbus-IHLHywN32M
unix 14 [ ] DGRAM 6711 - /dev/log
unix 2 [ ] DGRAM 2987 - @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 8304 - @/org/bluez/audio
unix 2 [ ACC ] STREAM LISTENING 8449 - @/tmp/.X11-unix/X0
unix 2 [ ACC ] STREAM LISTENING 8302 - /var/run/sdp
unix 2 [ ] DGRAM 3319 - @/org/kernel/udev/udevd
unix 2 [ ACC ] STREAM LISTENING 10688 3713/dbus-daemon @/tmp/dbus-rIAlJJw9nJ
unix 2 [ ] DGRAM 7640 - @/org/freedesktop/hal/udev_event
unix 2 [ ACC ] STREAM LISTENING 8597 - /var/run/avahi-daemon/socket
unix 2 [ ACC ] STREAM LISTENING 6814 - /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 10779 3725/scim-helper-ma /tmp/scim-helper-manager-socket-mad
unix 2 [ ACC ] STREAM LISTENING 10783 3726/scim-panel-gtk /tmp/scim-panel-socket:0-mad
unix 2 [ ACC ] STREAM LISTENING 10794 3723/gconfd-2 /tmp/orbit-mad/linc-e8b-0-14e7c774edb26
unix 2 [ ACC ] STREAM LISTENING 11040 3721/gconf-helper /tmp/orbit-mad/linc-e89-0-33ecc04e28ae4
unix 2 [ ACC ] STREAM LISTENING 11050 - /tmp/.esd-1000/socket
unix 2 [ ACC ] STREAM LISTENING 11053 -
.....
.....
.....