The original version of this content is here.

Setting up a VNC Server on a CentOS 6.5 NeCTAR instance

How to get a GUI interface to a virtual machine. These instructions are written for the NeCTAR Centos 6.5 image.  For other base OS installs (e.g. Ubuntu) you will need to substitute the default account name, and install the corresponding packages using the appropritae package installer.

The instructions configure the VNC server to use SSH tunnelling as a security measure.

Step-by-step guide

These instructions assume that you have already got a NeCTAR VM instance (based on the NeCTAR Centos 6.5 image) up and running and have ssh access to the VM.

  1. ssh into your instance:
    $ ssh
    • substitute in the IP address of your nectar instance. You can find this on the NeCTAR dashboard.
  2. Install the required packages:
    $ sudo yum groupinstall Desktop 
    • installs the packages required to setup a minimal desktop that can be used as a thin client
    • type yum groupinfo Desktop to see what packages will be installed when you run this
    $ sudo yum install tigervnc-server
    • install the vnc server
    $ sudo yum install xorg-x11-fonts-Type1
    • optional - installs some additional fonts
    $ sudo yum install vnc 
    • installs the vnc client
  3. Edit /etc/sysconfig/vncservers and add the following to the end of the file:
    VNCSERVERARGS[1]="-geometry 1024x600 -nolisten tcp -localhost""
    This assumes you are going to vnc into the ec2-user account - if using an account other then ec2-user then substitute username accordingly.

    It also sets up the vncserver so that it can only be connected to via an ssh tunnel - this is a security measure. To remove this just leave off the -nolisten tcp -localhostfrom the VNCSERVERARGS[1].
    The number used in the VNCSERVERS statement is significant - it indicate what port to connect to. VNC use port 5900 + the number. So in this case, the vnc server for the ec2-user will be available on port 5901.
  4. Make a vnc password for the user. Login to the user and run the following command:
    $ vncpasswd
  5. If you want to start your vnc server automatically on every reboot, run the following:
    $ sudo chkconfig vncserver on
    If you just want to start the vncserver manually use
    $ sudo service vncserver start
  6. To check that the vncserver is running
    $ service vncserver status
    Xvnc (pid 17709 17663) is running...
  7. If you have configured the VNCSERVERARGS as per instructions in step #3 you will need to set up an ssh tunnel on your desktop machine to connect to the server. If you are using a Linux or Mac OSX system, open a terminal window and use the following command:
    ssh -L 15901:localhost:5901 -N -f -l ec2-user

    If you are on a Windows machine, you will need to use PuTTY to set up the ssh tunnel. See for instructions on how to do this.
  8. Now start a VNC viewer on your local machine and connect to localhost using port 15901 ( You will be prompted for the vnc password that you created in step #4. If you don't have a vnc viewer, a google search should reveal numerous free options.

    If you are on a Mac, you can use the "Connect to Server" functionality in Finder:
  9. This will open Screen Sharing and prompt for the vnc password. If you don't get prompted for the password then there is some problem with the ssh tunnel. To debug this, add the flags -vvv to the ssh command in step #7 to try and diagnose what is going wrong.


  1. el Khamlichi, M. (2013, August 22). Install VNC Server on CentOS 6.4. Retrieved April 24, 2014 from
  2. Shine Servers (2013, November 24). How to Install VNC Server On CentOS. Retrieved April 24, 2014 from
  3. Nix Craft (2006, May 8). HowTo: Tunneling VNC Connections Over SSH. Retrieved April 24, 2014 from
  4. Prashar, Vinay (2008, September 25). How Connect to a VNC Server in MAC OSX Leopard. Retrieved April 24, 2014 from
  5. Bartlett, Alan (2012, November 07). VNC (Virtual Network Computing). Retrieved April 24, 2014 from
  6. DiSante, Anthony (2014). Controlling a Computer Remotely with VNC. Retrieved April 29, 2014 from