EGOPOLY

Topics include: programming, Apple, Unix, gadgets, large-scale web sites and other nerdy stuff.

How to use VNC server on CentOS

2006-09-08 13:51:54

Assume you have CentOS installed with Gnome. If you want to remotely access the GUI to that machine, you can use vnc-server and a vnc client (like Chicken of the VNC). Here's how:

ssh to the machine. If it is behind a firewall, you might have to set up a tunnel.
Make sure vnc-server is installed:

% sudo yum install vnc-server

Run vnc-server:

% vnc-server

This is just to initially create configs and choose a password. Now Edit the file ~/.vnc/xstartup so it runs a gnome session instead of crappy twm:

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

Kill off your vnc server and restart it:

% killall Xvnc
% vnc-server

Connect to your vnc server with host and display number reported with your favorite client. Yay.