Remote Desktop for Centos 4.7

I found help from a variety of sources on setting up “Remote Desktop” on the command line for a linux server system, for example, a headless virtual machine that’s remotely hosted.  Notes are for Centos 4.7 but easily apply to others.

First, install vnc server:  (probably need root permissions to do this)

yum install vnc-server

Then the gnome desktop packages:

yum groupinstall "X Window System" "GNOME Desktop Environment"

Then edit the vnc config file:

nano /etc/sysconfig/vncservers

Make it look like this: (heed the warnings about untrusted networks!)

# 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 # .  VNCSERVERS="1:dynamodan" VNCSERVERARGS[1]="-geometry 800x600"

Then add the user to vnc’s user list: (this assumes that the user ‘dynamodan’ already exists)

su dynamodan vncpasswd exit

Edit the /home/dynamodan/.vnc/xstartup file:

nano /home/dynamodan/.vnc/xstartup

and make it look like this:

#!/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 & # startx & exec gnome-session &

Finally, set up a screensaver to protect any gnome sessions that you left logged in. If anything goes wrong with the running vncserver, you can always telnet or shell into the server and do

 service vncserver restart 

I find that I need to do this sometimes.

Leave a Reply