Home > Software, Technology > CentOS VNC quick guide


CentOS VNC quick guide

March 16th, 2012


1. Installing the required packages

Check if vnc-server is already installed by running the command rpm -q vnc-server

If the server is not installed, install it with the command: yum install vnc-server

Make sure to install a window manager in order to get a normal GUI desktop. You can use the command yum groupinstall “GNOME Desktop Environment” to install the Gnome Desktop and requirements, for example.

2. Configuring un-encrypted VNC

You will perform the following steps to configure your VNC server:

  1. Create your VNC users.
  2. Set your users’ VNC passwords.
  3. Edit the server configuration.
  4. Create and customize xstartup scripts.
  5. Start the VNC service.
  6. Test each VNC user.
  7. Setup the VNC service to start on reboot.
  8. Additional optional enhancements

2.1. Create your VNC users

As root:

$ su -
# useradd marvin
# passwd marvin

2.2. Set your users’ VNC passwords

Login to each user, and run vncpasswd . This will create a .vnc directory.

[~]$ cd .vnc
[.vnc]$ ls
passwd

2.3. Edit the server configuration

Edit /etc/sysconfig/vncservers, and add the following to the end of the file.

VNCSERVERS="1:marvin"
VNCSERVERARGS[1]="-geometry 640x480"

2.4. Create xstartup scripts ( Skip this step for CentOS 6 )

We will create the xstartup scripts by starting and stopping the vncserver as root.

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

Login to each user and edit the xstartup script. To use Larry as an example, first login as larry

[~]$ cd .vnc
[.vnc] ls
mymachine.localnet:1.log  passwd  xstartup

Edit xstartup. The original should look like:

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

Add the line indicated below to assure that an xterm is always present, and uncomment the two lines as directed if you wish to run the user’s normal desktop window manager in the VNC. Note that in the likely reduced resolution and color depth of a VNC window the full desktop will be rather cramped and a look bit odd. If you do not uncomment the two lines you will get a gray speckled background to the VNC window.

#!/bin/sh
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

2.5. Start the VNC server

Start the vncserver as root.

# /sbin/service vncserver start

2.6. Test each VNC user

2.6.1. Testing with a java enabled browser

Let us assume that mymachine has an IP address of 192.168.0.10. The URL to connect to each of the users will be:

Marvin is http://192.168.0.10:5801

2.6.2. Testing with a vnc client

Install a vnc client on your PC eg from RealVNC

Access with 192.168.0.10:1

2.6.3. Starting vncserver at boot

To start vncserver at boot, enter the command /sbin/chkconfig vncserver on.

For basic VNC configuration the procedure is now complete.

For more details and with enhanced security, visit http://wiki.centos.org/HowTos/VNC-Server

 Follow me on twitter.





Software, Technology

,

You might like the following posts too :

  • » Amazon Web Services is taking over the cloud computing world
  • » Functional Thinking : Paradigm Over Syntax By Neal Ford
  • » Dart: Up and Running Review
  • » The Tech Entrepreneur's Survival Guide by Bernd Schoner
  • » Java EE 7 Platform Overview Webcast - Arun Gupta
    1. No comments yet.
    1. No trackbacks yet.