tigervnc使用總結


vncserver和x0vncserver用法總計

通常vncserver :port 會調用到xvnc,這時系統會新建一個虛擬桌面通過vncserver分享出去。

vncserver的用法很簡單:

 vncserver -h

usage: vncserver [:<number>] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 [-fp <font-path>]
                 [-fg]
                 [-autokill]
                 [-noxstartup]
                 [-xstartup <file>]
                 <Xvnc-options>...

       vncserver -kill <X-display>

       vncserver -list

若需要通過腳本使用vncserver,可使用如下方法:

su - $vncuser <<EOF
vncserver -kill $vncport
vncserver $vncport
EOF

 

而和vncserver不同,x0vncserver則是分享當前物理屏幕(類似於克隆),若通過vncserver方式出現問題,則可采用此方法。

x0vncserver常見用法:

x0vncserver -h
TigerVNC Server version 1.10.80, built Nov 28 2019 19:49:15

Usage: x0vncserver [<parameters>]
       x0vncserver --version

Parameters can be turned on with -<param> or off with -<param>=0
Parameters which take a value can be specified as -<param> <value>
Other valid forms are <param>=<value> -<param>=<value> --<param>=<value>
Parameter names are case-insensitive.  The parameters are:

Global Parameters:
  UseIPv6        - Use IPv6 for incoming and outgoing connections. (default=1)
  UseIPv4        - Use IPv4 for incoming and outgoing connections. (default=1)
  ZlibLevel      - Zlib compression level (default=-1)
  ImprovedHextile - Use improved compression algorithm for Hextile encoding
                   which achieves better compression ratios by the cost of
                   using more CPU time (default=1)
  pam_service    - Alias for PAMService
  PAMService     - Service name for PAM password validation (default=vnc)
  PlainUsers     - Users permitted to access via Plain security type (including
                   TLSPlain, X509Plain etc.) (default=)
  GnuTLSPriority - GnuTLS priority string that controls the TLS session’s
                   handshake algorithms (default=NORMAL)
  QueryConnect   - Prompt the local user to accept or reject incoming
                   connections. (default=0)
  AcceptSetDesktopSize - Accept set desktop size events from clients.
                   (default=1)
  SendCutText    - Send clipboard changes to clients. (default=1)
  AcceptCutText  - Accept clipboard updates from clients. (default=1)
  AcceptPointerEvents - Accept pointer press and release events from clients.
                   (default=1)
  AcceptKeyEvents - Accept key press and release events from clients.
                   (default=1)
  DisconnectClients - Disconnect existing clients if an incoming connection is
                   non-shared. If combined with NeverShared then new
                   connections will be refused while there is a client active
                   (default=1)
  NeverShared    - Never treat incoming connections as shared, regardless of
                   the client-specified setting (default=0)
  AlwaysShared   - Always treat incoming connections as shared, regardless of
                   the client-specified setting (default=0)
  Protocol3.3    - Always use protocol version 3.3 for backwards compatibility
                   with badly-behaved clients (default=0)
  FrameRate      - The maximum number of updates per second sent to each client
                   (default=60)
  CompareFB      - Perform pixel comparison on framebuffer to reduce
                   unnecessary updates (0: never, 1: always, 2: auto)
                   (default=2)
  ClientWaitTimeMillis - The number of milliseconds to wait for a client which
                   is no longer responding (default=20000)
  MaxIdleTime    - Terminate after s seconds of user inactivity (default=0)
  MaxConnectionTime - Terminate when a client has been connected for s seconds
                   (default=0)
  MaxDisconnectionTime - Terminate when no client has been connected for s
                   seconds (default=0)
  IdleTimeout    - The number of seconds after which an idle VNC connection
                   will be dropped (zero means no timeout) (default=0)
  MaxCutText     - Maximum permitted length of an incoming clipboard update
                   (default=262144)
  RemapKeys      - Comma-separated list of incoming keysyms to remap.  Mappings
                   are expressed as two hex values, prefixed by 0x, and
                   separated by -> (default=)
  Blackl

1、首先通過vncpasswd新建一個vnc密碼。

2、將物理桌面轉發出去。

x0vncserver -rfbport 5901 -display :0 -PasswordFile ~/.vnc/passwd

其中:

-rfbport 指定轉發到哪個端口,默認為5900。

-display 指定轉發哪個物理顯示器(若存在多個顯示器的情況下)。

-PasswordFile 指定密碼文件

A VNC  server is already running as :xx

當提示這個錯誤時我們會習慣性想到端口被占用,我們執行vncserver -kill :xx即可,但有時候這種方法就不靈了。

 

明明提示已經沒有這個進程了,當執行vncserver :xx時還是說端口已在使用。

並且執行lsof :59xx時並沒有其他進程占用此端口。

真這么神奇?腦殼大。。。

但理智告訴我肯定是有原因的,於是我看看了vncserver這個命令其實是一個perl腳本(PS:我們可以在這里修改vnc的默認端口,比如從59xx改到39xx。)

看看了vncserver這個腳本頓時茅塞頓開。

 

除了默認的59xx端口,Xvnc進程還會用到60xx端口。

於是我馬上看了看60xx端口的使用情況。

 

What?其他進程占用了這個端口。kill掉這個進程,重新執行vncserver :xx后成功啟動vnc。

 

正常啟動后我們可以看到Xvnc會同時用到兩個端口,但對外連接的應該是那個非60xx端口。

至此問題得到解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM