Install TightVNC Server in RHEL/CentOS and Fedora to Access Remote Desktops

Virtual Networking Computing (VNC) is a Kind of remote sharing system that makes it possible to take control of any other computer connected to internet. Keyboard and mouse clicks can easily transmit from one computer to another. It helps administrator and technical staff to manage their servers and desktops without being to the same location physically.

VNC is an open source application created in late 1990’s. It is independent and is compatible with Windows and Unix/Linux. Means a normal Windows based user can interact with Linux based system without any hazel.

To use VNC you must have TCP/IP connection and VNC viewer client to connect to a computer running VNC server component. The server transmits a duplicate display of a remote computer to the viewer.

This artilce demonstrates how to install VNC Server using TightVNC a much enhanced version of a older VNC program, with GNOME Desktop remote access on RHEL, CentOS and Fedora systems.

Step 1: Installing GNOME Desktop

If you’ve installed a minimal version of Operating System, which gives only a command-line interface not GUI. Then you need to install a GUI (Graphical User Interface) with GNOME Desktop. The GNOME desktop provides a lightweight desktop environment that works very well on remote VNC desktops.

[[email protected] ~]# yum groupinstall "X Window System" "Desktop"

Step 2: Installing TightVNC Server

TightVNC a remote desktop control software that enables us to connect to remote desktops. To install, use the following yum command as shown below.

[[email protected] ~]# 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 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

Create a new password for newly created user. Login to the user (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 SSH.

[[email protected] ~]# su - tecmint
[[email protected] ~]$ vncpasswd

The above command ask you to supply password twice and creates “.vnc” directory under user’s home directory with passwd file inside it. You can check the password file is created, by using following command.

# ls -l /home/tecmint/.vnc
-rw------- 1 tecmint tecmint 8 Jul 14 21:33 passwd

Now exit from user login and return to root user login.

[[email protected] ~]$ exit

Step 5: Create VNC Xstartup Script

Create the xstartup script as root user. This can be created by starting the VNC server.

[[email protected] ~]# /etc/init.d/vncserver start

Starting VNC server: 1:tecmint 
New ' (tecmint)' desktop is

Starting applications specified in /home/tecmint/.vnc/xstartup
Log file is /home/tecmint/.vnc/
						 [  OK  ]

Next, check whether xstartup script is created under (tecmint) user’s home directory, do “ls -l” command.

[[email protected] ~]# ls -l /home/tecmint/.vnc/
-rw-------. 1 tecmint tecmint    8 Jul 15 12:27 passwd
-rwxr-xr-x. 1 tecmint tecmint  654 Oct 11  2012 xstartup

Once, it created,  set a desktop resolution in xstartup file. For this, you must stop running VNC service.

[[email protected] ~]# /etc/init.d/vncserver stop

Shutting down VNC server: 1:tecmint              [  OK  ]

Step 6: Setting Xstarup Resolution

Open file “/etc/sysconfig/vncservers” file your choice of editor. Here I’m using “nano” editor.  Create new VNC Session for “tecmint” with below command. where “-geomerty” is used define desktop resolution.

[[email protected] ~]# nano /etc/sysconfig/vncservers

And add following lines to it at the bottom of file. Save and close it.

## Single User ##
VNCSERVERARGS[1]="-geometry 1280x1024"

If you’re dealing with multiple users, first create a vncpasswd for all user’s as described above in step 4, and then add those user’s to the VNCSERVERS line and add a VNCSERVERARGS[x] entry as shown below. Where ‘x‘ is the ID number.

## Multiple Users ##
VNCSERVERS="2:ravi 3:navin 4:avishek"
VNCSERVERARGS[2]="-geometry 1280x1024"
VNCSERVERARGS[3]="-geometry 1280x1024"
VNCSERVERARGS[4]="-geometry 1280x1024"

Step 7: Starting TightVNC Server

After making all changes, run the following command to start again the VNC server. Before starting VNC session to “tecmint” user, let me give you a small intro about Port Numbers and ID‘s. By Default VNC runs on Port 5900 and ID:0 (which is for 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 say (user5) then he will get port 5905 and id:5 and so on for each user you creates.

[[email protected] ~]# /etc/init.d/vncserver start

Starting VNC server: 1:tecmint 
New ' (tecmint)' desktop is

Starting applications specified in /home/tecmint/.vnc/xstartup
Log file is /home/tecmint/.vnc/

New ' (ravi)' desktop is

Starting applications specified in /home/ravi/.vnc/xstartup
Log file is /home/ravi/.vnc/

New ' (navin)' desktop is

Starting applications specified in /home/navin/.vnc/xstartup
Log file is /home/navin/.vnc/

New ' (avishek)' desktop is

Starting applications specified in /home/avishek/.vnc/xstartup
Log file is /home/avishek/.vnc/

                                                           [  OK  ]

Step 8: Open VNC Ports on Firewall

Open port on iptables, say for user (tecmint) at 5901.

[[email protected] ~]# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

For multiple users, ravi, navin and avishek. I open ports 5902, 5903 and 5904 respectively.

[[email protected] ~]# iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5902:5904 -j ACCEPT

Restart Iptables service.

[[email protected] ~]# service iptables save
[[email protected] ~]# service iptables restart

Step 9: Download VNC Client

Now go to your Windows or Linux machine and download VNC Viewer client and install in your system to access the desktop.

  1. Download VNC Viewer

Step 10: Connect to Remote Desktop Using Client

After you installed the VNC Viewer client, open it you’ll get similar to below screen. Enter VNC Server IP address along with VNC ID (i.e 1) for user tecmint.

VNC Server Login Details

Enter VNC Server IP Address

Enter password that we created with “vncpasswd” command.

Enter VNC User Password

Enter VNC User Password

That’s it, you connected to your Remote Desktop.

VNC Remote Desktop

VNC Remote Desktop

Read Also : Access VNC Desktop from Web Browser

Reference Link

TightVNC Homepage

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

42 Responses

  1. Rahul P.S says:

    Hello Ravi,

    I am using fedora 27. In this version /etc/sysconfig/vncservers is replaced by /lib/systemd/system/[email protected].

    I just followed this document to set up vncserver in my system. It was working fine till version 25. But now all I get is a blank screen after entering the password.

    What could be the reason ? any idea?

  2. martin says:

    Hi, thanks for the nice tutorial!

    Unfortunately i have some issues.

    After following the steps, log in fails from VNC viewer, with error message “the connection was closed unexpectedly”.
    Examining the log in /home/my_username/.vnc i notice the lines

    gnome-session[11753]: WARNING: Could not connect to ConsoleKit: Failed to connec
    t to socket /var/run/dbus/system_bus_socket: No such file or directory

    ** (gnome-settings-daemon:11785): WARNING **: Connection failed, reconnecting…

    Any help much appreciated.

  3. Bala says:

    Hi Ravi,

    I am getting the below error when i am trying to start the vncserver service by /etc/init.d/vncserver start.

    [[email protected] ~]# /etc/init.d/vncserver start
    Starting VNC server: 1:testing xauth: timeout in locking authority file /root/.xauth


    Please show me how configure ssh tunnel with VNC with steps

  5. Aktar Alam says:

    Hi Ravi,
    I followed your steps.
    it worked fine ….
    But my requirement was to configure the multiple vnc clients for the same user. For e.g say user techmint.
    So i added entry for the same in /etc/sysconfig/vncservers file as:
    VNCSERVERS=”1:techmint 2:techmint”
    VNCSERVERARGS[1]=”-geometry 1280×1024″
    VNCSERVERARGS[2]=”-geometry 1280×1024″

    After restarting the service I am getting black and X as cursor.
    Could you help me out???

    • Ravi Saive says:


      I think you can’t create multiple VNC sessions for same user, have you tried with different multiple users? is the VNC sessions worked for all?

      • Aktar Alam says:

        Hi Ravi,

        Thanks for the reply.
        I am able to create multiple VNC sessions for same user and currently I got them working by modifying the xstartup file .
        My xstartup file contents are below:

        # Uncomment the following two lines for normal desktop:
        unset SESSION_MANAGER
        exec /etc/X11/xinit/xinitrc
        gnome-session &
        [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
        [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
        xsetroot -solid grey
        vncconfig -iconic &
        #xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
        #twm &

        my vncservers file content is :
        [[email protected] ~]# cat /etc/sysconfig/vncservers
        # The VNCSERVERS variable is a list of display:user pairs.
        # Uncomment the lines below to start a VNC server on display :2
        # 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
        # .

        # Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

        # Use “-nohttpd” to prevent web-based VNC clients connecting.

        # Use “-localhost” to prevent remote VNC clients connecting except when
        # doing so through a secure tunnel. See the “-via” option in the
        # `man vncviewer’ manual page.

        # VNCSERVERS=”2:myusername”
        # VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”
        VNCSERVERS=”1:user1 2:user1 3:user1 4:user1 5:user1 6:user1″
        VNCSERVERARGS[1]=”-geometry 1280×1024″
        VNCSERVERARGS[2]=”-geometry 1280×1024″
        VNCSERVERARGS[3]=”-geometry 1280×1024″
        VNCSERVERARGS[4]=”-geometry 1280×1024″
        VNCSERVERARGS[5]=”-geometry 1280×1024″
        VNCSERVERARGS[6]=”-geometry 1280×1024″

        Now my issue is that I am able to invoke only two sessions for third session it flags below error:
        A VNC server is already running as :3

        • Ravi Saive says:


          Thanks for sharing your findings and configuration of both files, hope it will help others who looking for similar problems, about multiple VNC sessions for same users, i really don’t have idea, i need to check and get back to you..

  6. Michael Tagui says:

    Thanks a lot man, i really like your tutorial, it really makes the installation very easy…
    You deserve 100 stars

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.