About the author

Steven Harmansteven harman :: makes sweet software with computers!

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

Badges

  • Subtext Project
  • Support Subtext

VNC to a Headless Ubuntu Box

I’ve been doing a good amount of Ruby development lately and I really wanted to have a dedicated box to use as an internal (w/in my house) CI box… and possibly a staging server to host some Rails apps I was playing with. Anyhow, I had an old, unused box sitting in the basement – perfect!

I installed the latest Ubuntu bits, 8.04 (Hardy Heron) and had the box up and running in no time. However, as I intended to keep this box in the basement, without a monitor, keyboard, or mouse, I needed to be able to access and administer it remotely.

Granted, most of the work I’d need to do could be accomplished via SSH, but there were a few things I was going to need a GUI for – I needed remote desktop! Or just VNC. :)

Going headless

Ubuntu does support VNC out of the box, but you need to have an active X-Windows (Gnome, KDE, etc…) session already running before you fire up the VNC server.

But this was going to be a headless box! So short of hauling a monitor and keyboard to the basement every time I needed to bounce the box, which is rare, I had no way to get an X session started.

VNC Server, to the rescue!

To enable full GUI remote login you need a VNC server instance running on the box, and you need to launch an x session – I’m a Gnome guy myself, so we’ll go that route.

  1. SSH into the box and install TightVNCServer
    • sudo apt-get install tightvncserver
  2. Set Gnome to start when your VNC session starts
    • vi ~/.vnc/xstartup
    • #!/bin/sh
      
      xrdb $HOME/.Xresources
      xsetroot -solid black
      gnome-session &
  3. Start the VNC Server
    • vncserver –geometry widthxheight –depth 24
    • You will probably be prompted to enter a password that you'll use later to connect to this VNC session... so enter one!
  4. Start your VNC client on the remote machine, enter the password from step 3, and enjoy!

One side note. After logging into my VNC session I noticed that my keyboard mappings were all jacked-up. For example, typing asdf would result in abfh. After some searching, this appears to be an issue w/Gnome, but luckily I also found a workaround.

Oh… and you should probably be connecting to your VNC session via an SSH tunnel, but that’s a topic for another blog post… or use your Google-fu!

Technorati Tags: ,,

What others are saying.

# re: VNC to a Headless Ubuntu Box
Gravatar alberto
Dec 13, 2008
The latest Ubuntu version is 8.10 (Intrepid Ibex).

What do you need a GUI for?
# re: VNC to a Headless Ubuntu Box
Gravatar Steven Harman
Dec 13, 2008
@alberto, Thanks for pointing out that the latest Ubuntu release is in fact 8.10, and not 8.4 as I mentioned in my post. But I have an excuse!

When I actually set the box up, a few weeks ago, the Hardy Heron really was the latest release! :)

As for why I need a GUI - as I said, most of the time I don't. But I do plan to occasionally use the box to test browser compatibility and possibly to try out JetBrain's new Ruby IDE, RubyMine. That, and just b/c I wanted to see if I could do it.
# re: VNC to a Headless Ubuntu Box
Gravatar shane murnion
Dec 18, 2008
I also run a headless ubuntu server (ubuntuX) and vnc isn't a bad solution (I originally started out with that), but I switched to NX nomachine and haven't looked back.

Performance is outstanding. It feels like I'm working at a terminal physically connected to the server - even from a remote client. Definately worth a look and it's free - at least the linux server/ linux or windows client combination is.

http://www.nomachine.com/






# re: VNC to a Headless Ubuntu Box
Gravatar Leonardo C.
Feb 27, 2009
Silly question probably? I have to install gnome in my headless server in order to run a vnc server gnome-session.... right ?
# re: VNC to a Headless Ubuntu Box
Gravatar Steven Harman
Feb 27, 2009
@Leonard,
I would think that's the case, yes.
# re: VNC to a Headless Ubuntu Box
Gravatar Leonardo C.
Feb 27, 2009
Thanks Steven, I installed gnome :)
for some reason I was getting errors with the method depicted here(or maybe I didn't try hard enough). However I got things running with the one on my post URL.

Thanks again,
Comments have been closed on this topic.