VNC Server on CentOS 6

This post will cover installing VNC with GNOME Desktop on a remote server running CentOS 6.

Installation has changed a bit since CentOS 5, but is still simple and straight forward.

1. Install Tigervnc Server
  1. [root@demo ~]# yum -y install tigervnc-server
2. Install X Windows and GNOME.

This used to be yum groupinstall “X Window System” “GNOME Desktop Environment”, but is now simply:

  1. yum groupinstall “X Window System” “Desktop”
3. Create a user (or use and existing user) and create VNC login.
  1. [root@demo ~]# useradd david
  2. [root@demo ~]# passwd david
  3. Changing password for user david.
  4. New password:
  5. Retype new password:
  6. passwd: all authentication tokens updated successfully.
  7. [root@demo ~]# su – david
4. Switch to the user (su – user) and issue ‘vncpasswd’ to set the VNC password
  1. [david@demo ~]$ vncpasswd
  2. Password:
  3. Verify:
  4. [david@demo ~]$
5. Start VNC using ‘vncserver :1’
  1. [david@demo ~]$ vncserver :1
  2. xauth:  creating new authority file /home/david/.Xauthority
  3. New ‘demo.domain.net:1 (david)’ desktop is demo.domain.net:1
  4. Creating default startup script /home/david/.vnc/xstartup
  5. Starting applications specified in /home/david/.vnc/xstartup
  6. Log file is /home/david/.vnc/demo.domain.net:1.log
  7. [david@demo ~]$
6. Stop VNC using using ‘vncserver -kill :1’
  1. [david@demo ~]$ vncserver -kill :1
7. Setting resolution:

In /etc/sysconfig/vncservers, add a line for each user.

NOTE: if you if you need to install Oracle software, use geometry 1024×768.

You can also do this via the shell using: vncserver :1 -geometry 1024×768 -depth xx

  1. # The VNCSERVERS variable is a list of display:user pairs.
  2. #
  3. # Uncomment the lines below to start a VNC server on display :2
  4. # as my ‘myusername’ (adjust this to your own).  You will also
  5. # need to set a VNC password; run ‘man vncpasswd’ to see how
  6. # to do that.  
  7. #
  8. # DO NOT RUN THIS SERVICE if your local area network is
  9. # untrusted!  For a secure way of using VNC, see this URL:
  10. # http://kbase.redhat.com/faq/docs/DOC-7028
  11. # Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.
  12. # Use “-localhost” to prevent remote VNC clients connecting except when
  13. # doing so through a secure tunnel.  See the “-via” option in the
  14. # `man vncviewer’ manual page.
  15. # VNCSERVERS=”2:myusername”
  16. # VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -localhost”
  17. VNCSERVERS=“1:david”
  18. VNCSERVERARGS[1]=“-geometry 1024×768”

For multiple users, simply add the user to the VNCSERVERS list and add a VNCSERVERARGS[x] entry.

So for three users:

  1. VNCSERVERS=“1:david 2:bill 3:john”
  2. VNCSERVERARGS[1]=“-geometry 1024×768”
  3. VNCSERVERARGS[2]=“-geometry 1024×768”
  4. VNCSERVERARGS[3]=“-geometry 640×480”
8. Open the port for the user, in this case 5801.
  1. -A INPUT -m state –state NEW -m tcp -p tcp –dport 5801 -j ACCEPT

Save and restart IP Tables (/etc/init.d/iptables save | restart)

9. Connect using VNC Viewer with IP:1

10. You should now be connected to your CentOS desktop

CentOS Wiki: VNC ( Virtual Network Computing )

Advertisements
Leave a comment

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

%d bloggers like this: