Show Table of Contents
Chapter 13. TigerVNC
TigerVNC (Tiger Virtual Network Computing) is a system for graphical desktop sharing which allows you to remotely control other computers.
TigerVNC works on the client-server principle: a server shares its output (vncserver) and a client (vncviewer) connects to the server.
Note
Unlike in previous Red Hat Enterprise Linux distributions,
TigerVNC in Red Hat Enterprise Linux 7 uses the systemd system management daemon for its configuration. The /etc/sysconfig/vncserver configuration file has been replaced by /etc/systemd/system/vncserver@.service.
13.1. VNC Server
vncserver is a utility which starts a VNC (Virtual Network Computing) desktop. It runs Xvnc with appropriate options and starts a window manager on the VNC desktop. vncserver allows users to run separate sessions in parallel on a machine which can then be accessed by any number of clients from anywhere.
13.1.1. Installing VNC Server
To install the TigerVNC server, issue the following command as
root:
~]# yum install tigervnc-server
13.1.2. Configuring VNC Server
The VNC server can be configured to start a display for one or more users, provided that accounts for the users exist on the system, with optional parameters such as for display settings, network address and port, and security settings.
Procedure 13.1. Configuring a VNC Display for a Single User
- A configuration file named
/etc/systemd/system/vncserver@.serviceis required. To create this file, copy the/usr/lib/systemd/system/vncserver@.servicefile asroot:~]#cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.serviceThere is no need to include the display number in the file name becausesystemdautomatically creates the appropriately named instance in memory on demand, replacing'%i'in the service file by the display number. For a single user it is not necessary to rename the file. For multiple users, a uniquely named service file for each user is required, for example, by adding the user name to the file name in some way. See Section 13.1.2.1, “Configuring VNC Server for Two Users” for details. - Edit
/etc/systemd/system/vncserver@.service, replacing USER with the actual user name. Leave the remaining lines of the file unmodified. The-geometryargument specifies the size of the VNC desktop to be created; by default, it is set to1024x768.ExecStart=/usr/sbin/runuser -l USER -c "/usr/bin/vncserver %i -geometry 1280x1024" PIDFile=/home/USER/.vnc/%H%i.pid
- Save the changes.
- To make the changes take effect immediately, issue the following command:
~]#systemctl daemon-reload - Set the password for the user or users defined in the configuration file. Note that you need to switch from
rootto USER first.~]#su - USER~]$vncpasswdPassword: Verify:Important
The stored password is not encrypted; anyone who has access to the password file can find the plain-text password.
Proceed to Section 13.1.3, “Starting VNC Server”.
13.1.2.1. Configuring VNC Server for Two Users
If you want to configure more than one user on the same machine, create different template-type service files, one for each user.
- Create two service files, for example
vncserver-USER_1@.serviceandvncserver-USER_2@.service. In both these files substitute USER with the correct user name. - Set passwords for both users:
~]$su - USER_1~]$vncpasswdPassword: Verify:~]$su - USER_2~]$vncpasswdPassword: Verify:
13.1.3. Starting VNC Server
To start or enable the service, specify the display number directly in the command. The file configured above in Procedure 13.1, “Configuring a VNC Display for a Single User” works as a template, in which
%i is substituted with the display number by systemd. With a valid display number, execute the following command:
~]# systemctl start vncserver@:display_number.service
You can also enable the service to start automatically at system start. Then, when you log in,
vncserver is automatically started. As root, issue a command as follows:
~]# systemctl enable vncserver@:display_number.service
At this point, other users are able to use a VNC viewer program to connect to the VNC server using the display number and password defined. Provided a graphical desktop is installed, an instance of that desktop will be displayed. It will not be the same instance as that currently displayed on the target machine.
13.1.3.1. Configuring VNC Server for Two Users and Two Different Displays
For the two configured VNC servers, vncserver-USER_1@.service and vncserver-USER_2@.service, you can enable different display numbers. For example, the following commands will cause a VNC server for USER_1 to start on display 3, and a VNC server for USER_2 to start on display 5:
~]#systemctl start vncserver-USER_1@:3.service~]#systemctl start vncserver-USER_2@:5.service
13.1.4. VNC setup based on xinetd with XDMCP for GDM
VNC setup based on xinetd with X Display Manager Control Protocol (XDMCP) for GDM is a useful setup for client systems that consist mainly of thin clients. After the setup, clients are able to access the GDM login window and log in to any system account. The prerequisite for the setup is that the gdm, vnc, vnc-server & and xinetd packages are installed.
~]# yum install gdm tigervnc tigervnc-server xinetd
Service xinetd must be enabled.
~]# systemctl enable xinetd.service
System default target unit should be
graphical.target. To get the currently set default target unit, use:
~]# systemctl get-default
The default target unit can be changed by using:
~]# systemctl set-default target_nameProcedure 13.2. Accessing the GDM login window and logging in
- Set up GDM to enable XDMCP by editing the
/etc/gdm/custom.confconfiguration file:[xdmcp] Enable=true
- Create a file called
/etc/xinetd.d/xvncserverwith the following content:service service_name { disable = no protocol = tcp socket_type = stream wait = no user = nobody server = /usr/bin/Xvnc server_args = -inetd -query localhost -once -geometry selected_geometry -depth selected_depth securitytypes=none }In the server_args section, the-query localhostoption will make each Xvnc instance query localhost for an xdmcp session. The-depthoption specifies the pixel depth (in bits) of the VNC desktop to be created. Acceptable values are 8, 15, 16 and 24 - any other values are likely to cause unpredictable behavior of applications. - Edit file
/etc/servicesto have the service defined. To do this, append the following snippet to the/etc/servicesfile:# VNC xinetd GDM base service_name 5950/tcp
- To ensure that the configuration changes take effect, reboot the machine.Alternatively, you can run the following. Change init levels to 3 and back to 5 to force gdm to reload.
# init 3 # init 5
Verify that gdm is listening on UDP port 177.# netstat -anu|grep 177 udp 0 0 0.0.0.0:177 0.0.0.0:*
Restart the xinetd service.~]#systemctl restart xinetd.serviceVerify that the xinetd service has loaded the new services.# netstat -anpt|grep 595 tcp 0 0 :::5950 :::* LISTEN 3119/xinetd
- Test the setup using a vncviewer command:
# vncviewer localhost:5950
The command will launch a VNC session to the localhost where no password is asked. You will see a GDM login screen, and you will be able to log in to any user account on the system with a valid user name and password. Then you can run the same test on remote connections.
Configure firewall for the setup. Run the firewall configuration tool and add TCP port 5950 to allow incoming connections to the system.
~]#firewall-cmd --permanent --zone=public --add-port=5950/tcp~]#firewall-cmd --reload
13.1.5. Terminating a VNC Session
Similarly to enabling the
vncserver service, you can disable the automatic start of the service at system start:
~]# systemctl disable vncserver@:display_number.service
Or, when your system is running, you can stop the service by issuing the following command as
root:
~]# systemctl stop vncserver@:display_number.service
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.