How to configure CentOS/Fedora to allow for VNC Desktop Login

This is a snipt from the following Redhat Magazine Article.

This is post cuts to the chase on how to allow for a remote desktop session where VNC shows a login screen.

Why? Create a desktop manager session that allows a user to login remotely.

The article assumes VNC server is installed.

Setting up a persistent desktop

Here is a description of the steps to take when setting up a persistent desktop using VNC in Red Hat Enterprise Linux 4.

The first thing to do is set a password for the VNC server. To do this, log in as normal user (not root) and run the command vncpasswd from a shell prompt. The VNC service will not start unless you have set a password.

Next, become root using su - and edit the /etc/sysconfig/vncservers file. To set up two persistent desktop sessions, one for fred and one for joe (who prefers a larger display size than fred), it should look like Example 1. /etc/sysconfig/vncservers example.

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/vnc/sshvnc.html>.

VNCSERVERS="1:fred 2:joe"

# fred's VNC options
VNCSERVERARGS[1]="-geometry 1024x768"

# joe's VNC options
VNCSERVERARGS[2]="-geometry 1280x1024"
Example 1./etc/sysconfig/vncservers example

To start all VNC persistent desktops at boot, enable the VNC service with chkconfig vncserver on (as root). Then, to start the VNC persistent desktops now, type service vncserver start. Both users will be able to connect VNC viewers, fred to display number 1 and joe to display number 2.

The default desktop session in VNC is a very simple one, using the twm window manager. You might prefer the VNC desktop session to look and behave the same as the login session you would normally see. To do that, edit the file /home/username/.vnc/xstartup and remove the # from the beginning of the two lines that follow the line reading Uncomment the following two lines for normal desktop.