Earn Money with study Materials - Click Here To Know More

  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VNC Server Configuration On CentOS/RHEL
#1
Wink 
How to Setup VNC Server (Linux Remote Desktop Access) On CentOS/RHEL and Fedora
     To install VNC Server on a supported UNIX/Linux computer, follow the appropriate instructions for the platform at 
www.Annauniversityplus.com
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 sometimes 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 CentOSRHEL and Fedora Users.
STEP1: 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 Linux 5.X (CentOS/RHEL):


# yum groupinstall "GNOME Desktop Environment"




For Linux 6.X (CentOS/RHEL):


# yum groupinstall "Desktop"



For Linux 7.X (CentOS/RHEL):
# yum groupinstall "GNOME Desktop"

Now install few required packages for vnc-server:
PHP Code:
# yum install pixman pixman-devel libXfont 
PHP Code:
  
STEP 2: Install VNC Server:
After installing required packages, lets install vnc-server in your system. vnc-server is available under default yum repositories.
PHP Code:
# yum install vnc-server* -y 
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.
PHP Code:
# useradd Linuxtechi 
PHP Code:
# passwd Linuxtechi 
PHP Code:
# useradd Linuxtechi1 
PHP Code:
# passwd Linuxtechi1 
 
Now set the vnc password for all accounts need to connect through vnc.
PHP Code:
# su – Linuxtechi 
PHP Code:
vncpasswd 
PHP Code:
$ exit 
PHP Code:
# su – Linuxtechi1 
PHP Code:
vncpasswd 
PHP Code:
$ exit 
                            
Manually Creating Different Users in CentOS \RHEL:
STEP 3.1: Setup VNC Server Configuration File:
Copy the VNC config file “/lib/systemd/system/vncserver. Service” to the “/etc/systemd/system/vncserver@ :< Port Number>.service”.
While Copying the VNC config file we can mention the port number on which we want VNC service to be listen. In my case i am using port 3 , it means VNC will listen on “5903”. So while Connecting to the VNC server We can specify port number as or
PHP Code:
# cp [email]/lib/system/system/vncserver@.service[/email] /etc/system/system/vncserver@:3.service 
STEP 3.2: Update Users Information in the Configuration File:
PHP Code:
# vi /etc/systemd/system/vncserver@:1.service 
Replace the “Linuxtechi” user as per your requirement. In my case Linuxtechi user will able to control and manage its desktop session using remote VNC clients.
PHP Code:
Description=Remote desktop service(VNC
PHP Code:
After=Syslog.target network.target 
PHP Code:
[Service
PHP Code:
Type=forking 
PHP Code:
#Clean ay existing files in /tmp/.x11-unix environment 
PHP Code:
Exexstartpre=/bin/sh –c ‘/usr/bin/vncserver –kill %> /dev/null 2>&
PHP Code:
Exexstartpre=/sbin/runuser –l Linuxtechi –c “usr/bin/vncserver %1” 
PHP Code:
PIDFile=/home/Linuxtechi/.vnc/%H%i.pid 
 
As per above output, you can see that Linuxtechi desktop is available on: Linuxtech1 and user2 desktop is available on :2. We will use: 1 to connect to user1 and: 2 to connect to user2.
 
 
 
 STEP 4: Configure VNC Server For Users:
Now edit /etc/sysconfig/vncservers configuration file and add the following to the end of the file.
PHP Code:
VNCSERVERS="1:user1 2:user2" 
PHP Code:
VNCSERVERARGS[1]="-geometry 800x600" 
PHP Code:
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 for client.
 
Now start vnc-server service using following command and check the output:
For Linux 5.X(CentOS/RHEL)
PHP Code:
# service vncservice start 
PHP Code:
# service vncservice enable 
PHP Code:
# service vncservice status 
For Linux 6.X(CentOS/RHEL)
PHP Code:
# service vncservice start 
PHP Code:
# service vncservice enable 
PHP Code:
# service vncservice status 
 
For Linux 7.X(CentOS/RHEL):
PHP Code:
# systemctl start vncserver@:1.service 
PHP Code:
# systemctl enable 
PHP Code:
# systemctl status vncserver@:1.service 
Start and Enable the VNC Service at BOOT:
PHP Code:
# systemctl deamon-reload 
PHP Code:

STEP 5: Set the Firewall Rule if firewall is enabled on your linux box:
PHP Code:
# firewall-cmd –permanent –zone=public –add-port=5903/tcp 
PHP Code:
# firewall-cmd --reload 
STEP 5: Connect VNC Server Using VNC Viewer:
To access from remote Linux system use following command.
PHP Code:
# 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.../tigervnc/

After installing vnc viewer connect to your system, In below example we are connected to; 

   


Now enter vnc password of account assigned with vncpasswd command.

   

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

   

Regards,
Chinnasamy B.E
 
"Everything is POSSIBLE, even IMPOSSIBLE say's I'M POSSIBLE"
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)