HOWTO: Gnome CentOS VNC Server

19Mar13

This tutorial will outline how to install and configure a VNC Server on CentOS, similar to the Ubuntu VNC HowTo I did a while back.
This is particularly useful on headless servers, where you or other users still want to interact with a GUI.

Install the Packages

To install the VNC Server, open a terminal, and run the following command as root. (Use the su command to login as the root user, or, if you have it installed, use sudo.)

For CentOS 5:

yum install vnc-server

For CentOS 6:

yum install tigervnc-server

However, we now also need to install a Window Manager. In this tutorial, we’ll use Gnome, but you could use XFCE, KDE or whatever other WM you like.

To install Gnome and it’s requirements, run the following command as root.

For CentOS 5:

yum groupinstall "GNOME Desktop Environment"

For CentOS 6:

yum groupinstall "Desktop"

Configuring Un-Encrypted VNC

First we need to edit the config file to include all the users who will have VNC desktops.

To do that, edit /etc/sysconfig/vncservers to add the following lines;

VNCSERVERS="1:user1 2:user2 "
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 1024x768"

The VNCSERVERARGS array allows you to give each user’s VNC session different arguments. Here, user1 has a desktop resolution of 640×480, whereas user2 has a resolution of 1024×768. Read the vnc-server man pages for a full list of all the arguments you can provide.

Now, we must give every user a vnc password. To do this, we su into their account and run vncpasswd as follows. You can omit the first command (useradd) for existing users.

useradd user1
su user1
vncpasswd

This will create a .vnc directory in the user’s home, which will contain their passwd file. Do this for every user in the config file.

Almost done. Let’s check that the vnc server starts and stops correctly. This will check to make sure that you’ve correctly created the .vnc directory for every user.

/sbin/service   vncserver start
/sbin/service   vncserver stop

Finally, let’s startup the vnc server.

/sbin/service   vncserver start

Now you should be able to connect using a VNC client to your_server_ip:590X where X is the desktop number you want – eg 1 for user1, 2 for user2 etc

 

To Add

  • Encrypted VNC Server config
  • Detailed connecting instructions
  • Starting server at boot



Follow

Get every new post delivered to your Inbox.

Join 67 other followers

%d bloggers like this: