VNC Server on Xen Server Centos VM

VNC is a protocol that is used to share the desktop with other users/computers over the network/Internet.In order to share a desktop, VNC server must be install and configure on the computer and VNC client must be run on the computer that will access the shared desktop.

When we install the minimal copy of CentOS Server, it only gives us the “Command Line” interface.

But some people prefer GUI instead and for this they install Full version of Gnome on CentOS. Actually there is a better way and that is to install VNC. VNC provides a lightweight virtual desktop than full blown version of Gnome.

To run the VNC Server on CentOS, we have to install these required packages:

sudo yum groupinstall Desktop
sudo yum install tigervnc-server
sudo yum install xorg-x11-fonts-Type1

This is optional:

sudo yum install vnc

To start VNC Server on boot

sudo chkconfig vncserver on

To setup users’ VNC password:

vncpasswd

Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add the following to the end of the file:

VNCSERVERS="1:dev"
VNCSERVERARGS[1]="-geometry 1024x600"

The iptables rules need to be amended to open the VNC ports:

sudo iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
sudo service iptables save
sudo service iptables restart

Start the VNC Server as the user whom you want to connect. This will create the xstartup file in ~/.vnc folder

vncserver

Now kill the VNC Server:

vncserver -kill :1

Edit the xstartup file in .vnc directory:

nano .vnc/xstartup

Comment the last line and run the Gnome:

#twm & 
exec gnome-session &

Restart the service:

sudo service vncserver restart

Now, download VNCViewer onto our desktop computer from which we want to access the shared desktop. Connect using ServerIP/Name:1 (:1 is for the VNC server window), In my case it is centos:1.

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server.

Ability to connect for multiple users:

Create a local user, using the following command:

sudo adduser test

 

Create a password for newly created user:

sudo passwd test

Switch to the newly created user and run vncpasswd command for it:

su test
vncpasswd

Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add these lines for new user:

VNCSERVERS="1:arbab 2:test"
VNCSERVERARGS[1]="-geometry 1024x600"
VNCSERVERARGS[2]="-geometry 1024x600"

Restart the VNC service:

sudo service vncserver restart

Kill the vncserver session for new user and edit the xstartup file:

su test
vncserver -kill :2
cd ~
nano .vnc/xstartup

Modify the file so it looks like this:

#twm & 
exec gnome-session &

Restart the VNC service:

sudo service vncserver restart

Connect with newly created user using centos:2, Where centos is my server name:

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server for newly created user.

Advertisements

6 thoughts on “VNC Server on Xen Server Centos VM

  1. Pingback: LogicalDoc Install Instructions | Maanas Royy

  2. Do you know if this is still the work around for those having linux distros that cannot detect the pci devices in xenserver?

    • I m not sure. You can give a try. If you need any help let me know. What distro you have in mind. We exclusively used Centos and Scientific Linux and it worked. I believe it will also work for Ubuntu.

      • i tried centos 6.4, and the problem seems to be that the OS cannot detect the PCI devices through xencenter. startx will abend because it doesnt detect any devices, it gives that no screens found error after it rolls through all the normal device locations looking for something to use as a display. only way i am able to get into it is getting a vnc server running on it.

      • ive been reading about making sure your install is using a “xenified” kernel, so xencenter and centos can work as intended, i dont know if this is the cause of my problem.

      • We have installed using default CentOS Dvd and it worked. Which version of OS you are using. What is the processor of your server. Windows works in KVM env on Intel-VT only.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s