Skip to main content

VNC-Server installation on CentOS 7

Version 1.0 
Author: Srijan Kishore 
Last edited 1/Sep/2014
This guide explains how to configure VNC-server in CentOS 7.0 server. It is a very convinient way of administrating the CentOS 7.0 with the help of GUI(Graphics User Interface). The GUI can be access any where with the help of the VNC-client on any OS. The basic condition is that the connecting OS must have VNC-clients installed in it.
1 Preliminary Note
This tutorial is based on CentOS 7.0 server, so you should set up a basic CentOS 7.0 server installation before you continue with this tutorial. The system should have a static IP address. I use 192.168.0.100 as my IP address in this tutorial and server1.example.com as the hostname.
IP address 192.168.0.100
Gateway 192.168.0.1
DNS     8.8.8.8    8.8.4.4
Hostname server1.example.com

VNC-server benefits
  • Remote GUI administration makes work easy & convenient.
  • Clipboard sharing between host CentOS server & VNC-client machine.
  • GUI tools can be installed on the host CentOS server to make the administration more powerful
  • Host CentOS server can be administered through any OS having the VNC-client installed.
  • More reliable over ssh graphics.
  • More reliable over RDP connections.
2 Installation
I am logged in my system with root, & now I will be installing the VNC-server.

yum groupinstall "GNOME Desktop"
Further install 
 yum install tigervnc-server
3 Adding VNC user
In my case I am using user=srijan it will differ in your case. You can use any username for the same.

useradd srijan
In CentOS 7.0 there is change in the vncserver configuration file. Before ContOS 7.0 it was  /etc/sysconfig/vncservers and now it have changed in/lib/systemd/system/vncserver@.service. Next I will use the original file and create the configuration file as shown:
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Now we will edit the file as follows:
vi /etc/systemd/system/vncserver@:1.service
Replace the string <USER> with appropriate vncuser’s username.  In my case I will be using the user srijan just created above:
[...]
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStart=/sbin/runuser -l
srijan -c "/usr/bin/vncserver %i"
PIDFile=/home/
srijan/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
If you wish to add more users you would create a new vncserver@:#.service file and change the <USER> string to the new users.
Firewall settings:
firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload
Now switch to the vncuser just created above and start the vnc service as:
su - srijan
vncserver
[srijan@server1 ~]$ vncserver

You will require a password to access your desktops.

Password:<--yourvncpassword
Verify:<--yourvncpassword
xauth:  file /home/srijan/.Xauthority does not exist

New 'server1.example.com:1 (srijan)' desktop is server1.example.com:1

Creating default startup script /home/kishore/.vnc/xstartup
Starting applications specified in /home/kishore/.vnc/xstartup
Log file is /home/srijan/.vnc/server1.example.com:1.log

[srijan@server1 ~]$
Now make the service enabled on after every reboot with root credentials:
su -
systemctl daemon-reload
systemctl enable vncserver@:1.service
reboot
systemctl start vncserver@:1.service
4 VNC Client
At client end my OS is Ubuntu 14.04 with vino installed on my client machine. Otherwise you can install any VNC-client of your choice. In case other OS say Windows-7 you can install Realvnc-client or any other of your choice.
Now I am going to connect with the VNC server through my VNC-client at 192.168.0.100:5901
It will prompt for the password, give the vnc password just created above as follows:
Put yourvncpassword the same which you gave at the time of adding the user srijan.


Now you are connected with the CentOS 7.0 Server. In case you want to add more users to access the vnc-console you need to add :
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
vi /etc/systemd/system/vncserver@:2.service
For instance I am using user kishore, entries will be like this


[...]
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStart=/sbin/runuser -l
kishore -c "/usr/bin/vncserver %i"
PIDFile=/home/
kishore/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
Now switch to the vncuser just created above and start the vnc service as:
su - kishore
vncserver
[kishore@server1 ~]$ vncserver

You will require a password to access your desktops.

Password:<--yourvncpassword
Verify:<--yourvncpassword
xauth:  file /home/kishore/.Xauthority does not exist

New 'server1.example.com:2 (kishore)' desktop is server1.example.com:2

Creating default startup script /home/kishore/.vnc/xstartup
Starting applications specified in /home/kishore/.vnc/xstartup
Log file is /home/kishore/.vnc/server1.example.com:2.log

[kishore@server1 ~]$
Now  start the service on after every reboot for second user as follows:
systemctl daemon-reload
systemctl enable vncserver@:2.service
reboot
systemctl start vncserver@:2.service
This will enable user kishore to get the access to the VNC-server with the port 5902 as 192.168.0.100:5902 . In the same way you can add the root user also.

Congrats you have configured the VNC-server in CentOS 7.0 successfully :) 


Comments

Popular posts from this blog

VMware ESXi 5.5 Purple Diagnostic Screen Exception 14 in SEsparse and LibAIO (LibAIODrainMergeQueue, LibAIOMergedIODone, SESparseAsyncDataDone) (2073516)

Symptoms VMware ESXi 5.5 host fails with a purple diagnostic screen You see backtrace similar to: cpu0:33101)@BlueScreen: #PF Exception 14 in world 33101:memMap-0 IP 0x4180182f4948 addr 0x4108fffffff0 PTEs:0x100088063;0x80000020ad5bf063;0x0; cpu0:33101)Code start: 0x418018000000 VMK uptime: 1:09:27:02.593 cpu0:33101)0x4123c535cb20:[0x4180182f4948]LibAIODrainMergeQueue@vmkernel#nover+0x150 stack: 0x4130002a85c0 cpu0:33101)0x4123c535cb80:[0x4180182f53fd]LibAIOMergedIODone@vmkernel#nover+0x211 stack: 0x412ec622ef90 cpu0:33101)0x4123c535cbb0:[0x41801802d21f]AsyncPopCallbackFrameInt@vmkernel#nover+0xe7 stack: 0x1 cpu0:33101)0x4123c535cbe0:[0x418018bb9798]SESparseAsyncDataDone@esx#nover+0x15c stack: 0x41300007b0c0 cpu0:33101)0x4123c535cc10:[0x41801802d21f]AsyncPopCallbackFrameInt@vmkernel#nover+0xe7 stack: 0x4123c535cc70

How to configure an IP address in Solaris 11

Oracle made a huge changes in the networking stack with Solaris 11. The use of many network related files have been deprecated in Solaris 11. Below are some of the files which are not used in Solaris 11 for persistent network configuration : /etc/defaultdomain /etc/dhcp.* /etc/hostname.* /etc/hostname.ip*.tun* /etc/nodename /etc/nsswitch.conf Network Configuration Profile Solaris 11 uses profile-based network configuration. It has 2 configuration modes : 1. Automatic   – Uses DHCP to obtain network configuration (IP address, router and DNS) from any of the connected ethernet interfaces. Do not support hot swapping of interfaces and IPMP. 2. Manual (DefaultFixed NCP)   – interfaces needs to be manually configured using dladm and ipadm commands. Also called as DefaultFixed NCP. Supports hot swapping of interfaces and IPMP. Configuring the IP address Step 1 : Set the NCP We would set the NCP to DefaultFixed profile in order to configure the IP address manually

Visual Studio 2012 / 2013 Update 1 2 3 4 Offline Installer

Visual Studio 2012 Update 2 was released about a week ago.  This update includes lots of fixes and some features – you can see the list   here .  The only problem with the update is that Microsoft does not offer an offline installer.  If you are installing this on your own PC or for one person, you may not have a need for one.  But…  if your entire team needs to install this (or you just want to have it for later for a PC rebuild, you can download all 1.8 GB and have an offline installer for you or your team to share.  Here’s how: Get the update from Microsoft  here . (updated with Update 4 link) Save the file to a folder. open the folder Pro tip – Shift + right-click the background of the folder and choose ‘Open command window here’ in the command window type  VS2013.4.exe /Layout (or VS2013.1.exe /Layout or VS2013.2.exe /Layout depending on your update) It will then ask you where you would like to save and extrac