tigervnc使用总结

时间:2024-03-06 19:31:42

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端口。

至此问题得到解决。