Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»CentOS»How to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL and Fedora

    How to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL and Fedora

    By RahulMay 8, 20143 Mins Read

    VNC ( Virtual Network Computing ) Servers enables remote desktop access for Linux systems similar to MSTSC in windows. Generally Linux administrators doesn’t prefer to use windows access, But some times we required to have access remote desktop of Linux. In that case we need to install vnc server on our Linux system. This tutorial will help you to Setup VNC Server and configure remote access for users on CentOS, RHEL and Fedora Users.

    Advertisement

    Step 1: Install Required Packages

    Most of Linux servers doesn’t have desktop installed on their system. So make sure you have installed else use following command to install it.

    For CentOS/RHEL 6:
    # yum groupinstall "Desktop"
    
    For CentOS/RHEL 5:
    # yum groupinstall "GNOME Desktop Environment"
    

    Now install few required packages for vnc-server

    # yum install pixman pixman-devel libXfont
    

    Step 2: Install VNC Server

    After installing required packages, lets install vnc-server in your system. vnc-server is available under default yum repositories.

    # yum install vnc-server
    

    On CentOS/RHEL 6, you will see that tigervnc-server package will be installed.

    Step 3: Create User for VNC

    Lets’ create few users for connecting through vnc. You can also use existing system users by connecting through vnc, In that case we only need to set vncpasswd for that account.

    # useradd user1
    # passwd user1
    
    # useradd user2
    # passwd user2
    

    Now set the vnc password for all accounts need to connect through vnc.

    # su - user1
    $ vncpasswd
    $ exit
    
    # su - user2
    $ vncpasswd
    $ exit
    

    Step 4: Configure VNC Server for Users

    Now edit /etc/sysconfig/vncservers configuration file and add the following to the end of the file.

    VNCSERVERS="1:user1 2:user2"
    VNCSERVERARGS[1]="-geometry 800x600"
    VNCSERVERARGS[2]="-geometry 1024x768"
    

    Where VNCSERVERS is the list of users need to connect, VNCSERVERARGS defined the screen size. Like user1 have a 800×600 screen, and user2 have 1024×768 screen size on his client.

    Now start vnc-server service using following command and check the output

    # service vncserver start
    
    Starting VNC server: 1:user1 xauth:  creating new authority file /home/user1/.Xauthority
    
    New 'svr1.tecadmin.net:1 (user1)' desktop is svr1.tecadmin.net:1
    
    Creating default startup script /home/user1/.vnc/xstartup
    Starting applications specified in /home/user1/.vnc/xstartup
    Log file is /home/user1/.vnc/svr1.tecadmin.net:1.log
    
    2:user2 xauth:  creating new authority file /home/user2/.Xauthority
    
    New 'svr1.tecadmin.net:2 (user2)' desktop is svr1.tecadmin.net:2
    
    Creating default startup script /home/user2/.vnc/xstartup
    Starting applications specified in /home/user2/.vnc/xstartup
    Log file is /home/user2/.vnc/svr1.tecadmin.net:2.log
    
                                                               [  OK  ]
    

    As per above output, you can see that user1 desktop is available on :1 and user2 desktop is available on :2. We will use :1 to connect to user1 and :2 to connect to user2.

    Step 5: Connect VNC Server using VNC Viewer

    To access from remote Linux system use following command.

    # vncviewer 192.168.1.11:1
    

    To access remote desktop on vnc-server from windows system, you must have vnc-viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:

    TightVNC: http://www.tightvnc.com/download.php
    RealVNC: https://www.realvnc.com/download/vnc/
    TigerVNC: http://sourceforge.net/projects/tigervnc/files/tigervnc/

    After installing vnc viewer connect to your system, In below example we are connected to user1 (:1).

    connect-vnc

    Now enter vnc password of account assigned with vncpasswd command.

    vncviewer-password

    You are connected to x windows system of your Linux machine.

    vnc-connected

    remote-desktop vnc vncserver vncviewer
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Understanding 2>&1 in Bash: A Beginner’s Guide

    How to Choose the Best Shebang (#!) for Your Shell Scripts

    Modulus Operator (%) in Bash

    Using Modulus Operator (%) in Bash

    View 7 Comments

    7 Comments

    1. Martin on January 29, 2020 10:48 pm

      Instructions worked fine. But I get a new screen. Instead I’d like to have screen sharing with the actual remote machine.

      Reply
    2. Saba on October 21, 2017 11:15 am

      How to Setup VNC Server (Linux Remote Desktop Access) on Linux mint 17.3

      I need configuration for Above the mentioned

      Reply
    3. Rajesh on December 2, 2015 8:09 pm

      Hi,

      VNC works as expected. However I am having two issues :-

      1. When remote machine gets connected, how to make the display occupy the entire screen ( normally it occupies nearly 60% space with blanks on either side )?

      2. When I try to log out, the icons of remote system go off the screen but the base UI remains and never ends – any method of getting clear log-off ?

      Reply
    4. Resp on September 30, 2014 9:35 am

      By the way,
      # yum groupinstall “Desktop”
      or
      # yum groupinstall “GNOME Desktop Environment”
      on CentOS 7 occur
      > Warning: group does not exist

      Reply
    5. Resp on September 30, 2014 9:30 am

      CentOS 7
      # service vncserver start
      or
      $ sudo service vncserver start
      occur
      > Redirecting to /bin/systemctl start vncserver.service
      > Failed to issue method call: Unit vncserver.service failed to load: No such file or directory

      Reply
    6. Jo on June 4, 2014 3:55 pm

      Hi Rahul

      Your instruction looks great and it works fine.

      Instead of adding additional users like user1, user2 as mentioned in your document, what is the procedure to add the root user to the VNC users list and let Root user access the server via VNC?

      Looking forward for your response.

      Regards
      Jo

      Reply
      • sameer on June 18, 2014 5:36 am

        hi Jo,

        step1: vncpasswd for root.
        step2:vncviewer [email protected]:1

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.