vnc (tightvncserver)

最後更新: 2015-02-05

介紹

tightvncserver 是現時在 Linux 上效能最高的 VNC Server

它一共有 4 個執行檔, 分別如下

  • vncconnect  ---> /usr/bin/tightvncconnect
  • vncpasswd   ---> /usr/bin/tightvncpasswd
  • vncserver    ---> /usr/bin/tightvncserver
  • Xvnc           --->  /usr/bin/Xtightvnc

目錄

  • 介紹
  • 應用
  • 它的啟動 script
  • HTTP Web
  • 其他設定檔
  • 相關工具
  • Window 版
  • .................

 


Install

 

 


應用

 

1. 建立 password 檔案

user@xubuntu:~$ tightvncpasswd                  <------- 建立 VNC 所用到的 pw, 最長 8 位

Using password file /home/user/.vnc/passwd   <------- pw 檔案的位置

密碼共分為兩種

  • primary
  • view-only <------ 可以選擇不設定的

2. 啟動

tightvncserver       <----找一個未被使用的 port 啟動

tightvncserver:2   <---- 指定在那一個 port 啟動 (590n)

tightvncserver -geometry 640x480 -dpi 100  <----帶一些有用的參數啟動

3. 反向連接

反向連接是指 VNC Server 主動連上 Clinet

此功能是透過 vncconnect 來完成

Example:

vncconnect -display :1 192.168.123.2:5500

(Client Side 的 Defualt listen port 是 5500)

 

4. 停用 vnc server

vncserver -kill :1

 


它的啟動 script

 

VNC Server 是執行此 Script ~/.vnc/xstartup 去啟動一個 X 的

 

Example: 啟動 xfce

apt-get install xfce4 xfce4-goodies tightvncserver

chmod +x ~/.vnc/xstartup

#!/bin/bash
# xrdb 係非必要的
#xrdb $HOME/.Xresources
startxfce4 &

 


 

HTTP Web

 

加入此參數啟動 VNC Server (-httpport int)

 


其他設定檔

 

/etc/vnc.conf

~/.vncrc

$fontPath = "";       <---- 設定 font 的位置 xfs, 如果是在本地, 而且多個一個位置, 那可用 "," 分隔它們 
$geometry ="800x600";
$depth = "16";
$rfbwait = "120000";  <---- 會等 client 多數 msec 

 

log file:

/home/user/.vnc/xubuntu:N.log

 


相關工具

 

xset q 查詢機器

 



Window 版

 

注冊成為 Sevice

成為了 Sevice後, 那了可以自動執行, 而且可以見到"登入介面"

Register VNC Service:

winvnc4.exe -noconsole -register

Start VNC Service:

winvnc4.exe -noconsole -start

Stop VNC Service:

winvnc4.exe -noconsole -stop

Unregister VNC Service:

winvnc4.exe -unregister

Connect 去 viewer:

winvnc.exe -connect 192.168.88.177

 


Viewer Listening 

 

vncviewer.exe -listen

 


設定

 

它一共有兩組設定, 分別是"服務" 及 "用戶"設定

不過, 它們是互不相扞

vncconfig.exe  -service

vncconfig.exe" -user

 


vnc 用 gdm 去 login

 

Diagram

viewer ---> vncserver --> xdmcp
                     |
                 xserver

xinetd

service vnc
{
   disable     = no
   socket_type = stream
   protocol    = tcp
   wait        = no
   user        = nobody
   server      = /usr/bin/Xvnc
   server_args = -inetd -once -query localhost -geometry 1024x800 -depth 16
   type        = UNLISTED
   port        = 5900
}

-query localhost

This option tells the VNC X server to check with the localhost system for XDMCP authentication.

XDMCP support for VNC

/etc/X11/gdm/custom.conf   

[xdmcp]    
enable=true

 


Other

 

 


 

 

Creative Commons license icon Creative Commons license icon