1. Check whether vnc-server has been installed in the query system for execution:
Rpm-qa | grep vnc
For example:
vnc-server-
Vnc-server has been installed.
2. Configure the vnc-server user
First, add the user: Adduser Kevin Set User Password: Passwd Kevin Password: Verify:
|
The configuration file for configuring VNC-server, located: /Etc/sysconfig/vncservers The content is as follows: # The VNCSERVERS variable is a list of display: user pairs. # # Uncomment the line below to start a VNC server on display: 1 # As my 'myusername' (adjust this to your own). You will also # Need to set a VNC password; run 'man vncpasswd' to see how # To do that. # # Do not run this service if your local area network is # Untrusted! For a secure way of using VNC, see # URL: http://www.uk.research.att.com/vnc/sshvnc.html
# VNCSERVERS = "1: myusername" VNCSERVERS = "1: tchung "-----> here tchung is the user VNCSERVERARGS [1] ="-geometry 1024x768 "-----> here it means to configure parameters related to user tchung. Here there are two points note: 1. VNCSERVERS = supports multiple users, separated by spaces. For example, VNCSERVERS = "1: myusername 15: otheruser" ---> here, 1 and 15 are the port numbers used to connect to Port 2. the data in [] After VNCSERVERARGS must be consistent with the user value after VNCSERVERS. The basic VNCSERVERARGS parameters are as follows:-geometry desktop size. The default value is 1024x768. -Nohttpd does not listen to HTTP ports -Nolisten tcp does not listen to port X -Localhost only allows access from the Local Machine -Alwaysshared: by default, only one vncviewer connection is allowed at the same time (also related to client configuration). Once 2nd connections are connected, 1st are disconnected. This parameter allows multiple vncviewer connections at the same time. -Securitytypes none password authentication is not required for Logon. The default value is vncauth. password authentication is required. |
After the configuration is complete, we will use vncpass to set the authentication during vnc connection.
vncpass Password: Verify: Note that the vncpass here can only be run under the VNC user
|
After execution, the. vnc directory will be generated under the user directory. There is a file named passwd in it. Then we start vncserverservice vncserver start. If no error occurs, the vnc service will be started. Some files will be generated under the. vnc directory under the user directory of tchung. Now we want to modify xstartup
#! /Bin/sh # Uncomment the following two lines for normal desktop: (remove the following two lines # You can use the desktop) Unset session_manager Exec/etc/X11/xinit/xinitrc [-X/etc/VNC/xstartup] & exec/etc/VNC/xstartup [-R $ home/. Xresources] & xrdb $ home/. Xresources Xsetroot-solid gray Vncconfig-iconic & # Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "& # TWM & --- comment out the two lines and add gnome-session &
|
Restart vncserver and use netstat-antpl to check whether three ports are listening. 5901 5801 6001 the three ports: default, the vnc service listens to three TCP ports
RFB (Remote FrameBuffer) protocol default port: 5900 + display number
Default HTTP port: 5800 + display number
X protocol default port: 6000 + display number
The display number used by the vncserver starts from 1 by default. You can also specify the port number by specifying the RFB Protocol. Therefore, we can disable the ports 5800 and 6000. You need to modify the/etc/sysconfig/vncservers parameter followed by-nohttpd not listening to the HTTP port.
-Nolisten tcp does not listen to port X
# The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the line below to start a VNC server on display :1 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # For a secure way of using VNC, see # URL:http://www.uk.research.att.com/vnc/sshvnc.html # VNCSERVERS="1:myusername" VNCSERVERS="1:tchung" VNCSERVERARGS[1]="-geometry 1024x768 -nohttpd -nolisten tcp"
|
Restart vncserver and use vncview to connect to 192.168.107.109: 1 ----> here: 1 indicates that the port number is 5900 + 1. This 1 is specified in/etc/sysconfig/vncservers, this number is less than 100, and can be expressed directly with 192.168.107.109: 1 if it does not include 100, if the value specified in vncservers is greater than 100 and contains 100, the complete port value is used during connection. For example, if 100 is specified in vncservers, the connection should be like this: 192.168.107.109: 6000vnc uses the port 5900 by default, this should be changeable, but the source code must be changed.