Virtual Networking Computing (VNC) is a kind of remote sharing system that makes it possible to take control of any other computer connected to the internet. Keyboard and mouse clicks can easily transmit from one computer to another. It helps administrators and technical staff to manage their servers and desktops without being to the same location physically.
VNC is an open-source application created in the late 1990s. It is independent and is compatible with Windows and Unix/Linux. This means a normal Windows-based user can interact with Linux based system without any hazel.
[ You might also like: 11 Best Tools to Access Remote Linux Desktop ]
To use VNC you must have a TCP/IP connection and a VNC viewer client to connect to a computer running the VNC server component. The server transmits a duplicate display of a remote computer to the viewer.
This article demonstrates how to install VNC Server using TightVNC a much-enhanced version of an older VNC program, with GNOME Desktop remote access on RHEL-based Linux distributions.
Step 1: Installing GNOME Desktop
If you’ve installed a minimal version of the operating system, which gives only a command-line interface not GUI. Therefore, you need to install a GUI (Graphical User Interface) called GNOME Desktop, which works very well on remote VNC access.
# yum groupinstall "SERVER WITH GUI" OR # dnf groupinstall workstation
Step 2: Installing TightVNC Server
TightVNC is a remote desktop control software that enables us to connect to remote desktops. To install, use the following yum command as shown below.
# yum -y install tigervnc-server xorg-x11-fonts-Type1
Step 3: Create a Normal VNC User
Create a normal user, that will be used to connect to a remote desktop. For example, I’ve used “tecmint” as a user, you can choose your own username.
[[email protected] ~]# useradd tecmint [[email protected] ~]# passwd tecmint Changing password for user tecmint. New password: Retype new password: passwd: all authentication tokens updated successfully.
Step 4: Set VNC Password for User
First, switch to the user using (su – tecmint) and run ‘vncpasswd‘ to set the VNC password for the user.
Note: This password is for accessing VNC remote desktop, and the password we created in step 3 is for accessing the SSH session.
[[email protected] ~]# su - tecmint [[email protected] ~]$ vncpasswd Password: Verify:
The above command asks you to supply a password twice and creates the “.vnc” directory under the user’s home directory with a passwd file inside it. You can check the password file is created, by using the following command.
# ls -l /home/tecmint/.vnc -rw------- 1 tecmint tecmint 8 Jul 14 21:33 passwd
If you are adding another user, just switch to the user and add the vnc password with the vncpasswd command.
Step 5: Configure VNC for Gnome
Here, we will configure TigerVNC to access Gnome using the user configuration settings from the ~/.vnc/config file.
$ vim ~/.vnc/config
Add the following configuration to it.
session=gnome geometry=1920x1200 localhost alwaysshared
The session parameter defines the session you want to access, and the geometry parameter adds the resolution of the VNC desktop.
Now exit from user login and return to root user login.
TigerVNC comes with default configuration settings that allow you to map a user to a specific port in the /etc/tigervnc/vncserver.users file:
# vim /etc/tigervnc/vncserver.users
The configuration file uses
<display_port>=<username> parameters. In the following example, we are assigning display port
:1 to user tecmint.
# This file assigns users to specific VNC display numbers. # The syntax is =. E.g.: # # :2=andrew # :3=lisa :1=tecmint
If you are adding another user, just set the display port to
:2 followed by the username.
Step 6: Starting the Tigervnc Server
After making all changes, run the following command to start the VNC server. Before starting the VNC session with a “tecmint” user, let me give you a small intro about Port Numbers and ids.
By Default VNC runs on Port 5900 and ID:0 (which is for the root user). In our scenario, I’ve created tecmint, ravi, Navin, and avishek. So, the ports and id’s are used by these users as follows
User's Port's ID's 5900 root :0 5901 tecmint :1 5902 ravi :2 5903 navin :3 5904 avishek :4
So, here user “tecmint” will get port 5901 and id as :1 and so on. If you’ve created another user says (user5) then he will get port 5905 and id:5 and so on for each user you create.
To start and enable the VNC service for the user assigned to the display port
# systemctl start [email protected]:1 --now # systemctl enable [email protected]:1 --now
You can confirm that the VNC service is successfully started with:
# systemctl status [email protected]:1
To allow VNC access for other users, simply replace
1 with the display port number.
Step 7: Open VNC Ports on Firewall
Open port on iptables or firewalld, say for the user (tecmint) at 5901.
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT OR # firewall-cmd --zone=public --add-port=5901/tcp
For multiple users, ravi, navin, and avishek. I open ports 5902, 5903, and 5904 respectively.
# iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5902:5904 -j ACCEPT OR # firewall-cmd --zone=public --add-port=5902-5904/tcp
Restart Iptables service.
# service iptables save # service iptables restart Or # firewall-cmd --reload # systemctl restart firewalld
Step 8: Download VNC Client
Now go to your Windows or Linux machine and download the VNC Viewer client and install it in your system to access the desktop.
Step 9: Connect to Remote Desktop Using Client
After you installed the VNC Viewer client, open it you’ll get something similar to the below screen. Enter VNC Server IP address along with VNC ID (i.e 1) for user tecmint.
Enter the password that we created with the “vncpasswd” command.
That’s it, you connected to your Remote Desktop.
[ You might also like: How to Access Remote VNC Desktop from Web Browser Using TightVNC Java Viewer ]