CentOS VNC quick guide
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:
- Create your VNC users.
- Set your users’ VNC passwords.
- Edit the server configuration.
- Create and customize xstartup scripts.
- Start the VNC service.
- Test each VNC user.
- Setup the VNC service to start on reboot.
- Additional optional enhancements
2.1. Create your VNC users
$ 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="-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