VNC Server under Linux
Charles Roth, 9/4/2009
(TechBlog top)
I. Introduction & Purpose
There have been many occasions where I wanted to install software on a
remote linux server, but had to do some complicated navigation thru web pages
to actually get to and download the software.
It's a pain to download the software to my laptop, and then
re-upload it to the server -- and frequently slow, to boot,
as the server usually has a lot more bandwidth than my
laptop connection (think Panera, Barnes & Noble, etc...)
II. Solution. VNC Server
So the solution is to use a VNC client on my laptop to connect to a virtual
desktop on the server, which in turn is running the VNC server.
The results can be (visually speaking) somewhat ugly, but it works!
III. Installation details for RHEL 5 or CentOS 5
As root, do:
- yum install vnc.i386
- yum install vnc-server.i386
- yum install gnome-session.i386
- yum install gnome-utils.i386 (this step may be optional)
- yum install gnome-terminal.i386
- yum install firefox.i386 (presumably you want a browser...)
- vncserver
(this starts the vncserver, but clumsily.
It will ask for a password, which will be used when you
want to connect from a VNC client.)
- vncserver -kill :1  (kills the server)
- Edit the file .vnc/xstartup.
Uncomment the two lines it suggests uncommenting(!!).
The last line should be (or be replaced by) "exec gnome-session &".
- Change your firewall to allow incoming access on port 5901,
ideally for just a limited set of IP addresses.
- vncserver
(restarts the vncserver with all of the proper options)
IV. Installation details for RHEL 6 or CentOS 6
As root, do:
- yum install gtk-vnc.i686
- yum install tigervnc-server.i686
- yum install gnome-session.i686 (this step may be optional)
- yum install gnome-utils.i686 (this step may be optional)
- yum install firefox.i386 (presumably you want a browser...)
- vncserver
(this starts the vncserver, but clumsily.
It will ask for a password, which will be used when you
want to connect from a VNC client.)
- vncserver -kill :1  (kills the server)
- Edit the file .vnc/xstartup.
Uncomment the two lines it suggests uncommenting(!!).
The last line should be (or be replaced by) "exec gnome-session &".
- Change your firewall to allow incoming access on port 5901,
ideally for just a limited set of IP addresses.
- vncserver
(restarts the vncserver with all of the proper options)
V. Usage Notes
Normally I wouldn't just leave the vncserver running on the server.
So I just turn it on when I need it, then kill it.
- ssh/putty to the server, and just type "vncserver".
That will start up the VNC server.
- Use a vnc client in the normal way to connect,
except that the host will be (say) myhost.com:1.
- Once you're in, you'll see a web browser button on the menu
bar at the top.
That's probably the only reason you'll want to be using
vncserver in the first place.
Other tools (e.g. terminal/shell window) are available from the menus.
- When you're done, make sure to do a "vncserver -kill :1"
to kill the server.
- Unlike Windows, it's actually possible to have many vncservers
running on the same physical server (i.e. on ports 5901, 5902, etc).
Right now I can't think of any practical uses for that, but it's there.
Also unlike windows, there's no "main desktop session" to connect to,
since presumably the server is running "headless" -- no monitor!
Enjoy!
I hope this helps.
Feedback or other information is welcome at
roth@thedance.net.