Monday, October 25, 2010

Ubuntu 10.10 VNC Login Screen

I figured out how to get a graphical login screen over VNC on Ubuntu 10.10 today. The method that worked before Ubuntu 10.04 stopped working when XDMCP support was removed from gdm (source).

This procedure starts from a fresh install of Ubuntu-Desktop-10.10.

install xdm, vnc4server, and xinetd.
sudo apt-get install xdm vnc4server xinetd
When asked during installation what the default display manager should be, keep the setting as gdm.

Configure xdm to be able to answer XDMCP requests, comment out the following line in /etc/X11/xdm/xdm-config:
! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
!DisplayManager.requestPort:    0
Configure XDM to answer XDMCP requests from localhost, and to listen to just localhost by adding the following lines to /etc/X11/xdm/Xaccess:
LISTEN localhost

Configure XDM to not bring up a physical display by commenting out the following line in /etc/X11/xdm/Xservers:
#:0 local /usr/bin/X :0 vt7 -nolisten tcp

Configure the startup script to allow XDM to start despite gdm taking care of the screen by removing /etc/X11/default-display-manager:
sudo mv /etc/X11/default-display-manager /etc/X11/default-display-manager.disable

Add the VNC port definition to /etc/services if it has not already been added:
vnc 5900/tcp

Configure the VNC incoming port by creating /etc/xinetd.d/vnc:
service vnc
        only_from = localhost
        disable = no
        id = vnc
        socket_type = stream
        protocol = tcp
        wait = no
        user = nobody
        server = /usr/bin/Xvnc4
        server_args = -inetd -query localhost -once -SecurityTypes=None -pn -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -desktop Ubuntu
        log_on_failure += USERID
In this configuration connections are restricted to the local network (192.168.0.*).

After all these pieces are done, restart the services to load the new configurations:
sudo /etc/init.d/xdm restart
sudo /etc/init.d/xinetd restart

Now you should be able to use VNC to get a login screen.

There is a problem with gnome in this setup where it has a keyboard shortcut assigned to 'd', which can be fixed by going into System -> Preferences -> Keyboard Shortcuts and disabling, or reassigning the "Hide all normal windows and set focus to the desktop" shortcut key (source). This may happen because the default key binding is Mod4+D, and there is no Mod4 modifier key on the VNC connection.


  1. THANK YOU. i've been looking all over for 10.10 instructions for this, and so far found only pre-10.10 (which are no longer valid). :-D

  2. Thankyou very much.. This is literally the only detailed tutorial on setting up some kind of headless login to Ubuntu 10.10.

  3. What Squeeb said! Thanks very much, worked perfectly.

    May also want to note that you can modify the resolution by including something like

    -geometry 1280x900

    In the server_args section.

  4. As a Linux newbie I following this slavishly and it worked (using TightVNC as the remote Windows client), except for two things:

    1. As soon as I add a geometry entry to server_args - eg '-geometry 1280x1024' - I get the screen (of the right size), but no login prompt. Can only get the login prompt if I leave it at the (1024x768) default.

    2. How do I get it to power down remotely? If I use the remote power icon and shutdown entry, it breaks the TightVNC session, but the box does not shut down. I can only do that with a keyboard/mouse/monitor on the remote box, which slightly defeats the object.

    Comments appreciated.

  5. Nick W:

    1. I would expect that if i stick the geometry on the end of the command line it would work just fine, I will try that out later and see what happens.

    2. When I try to shut down a remote box I usually use the "shutdown" command in a shell, and often the connection is SSH instead of a graphical session.

  6. After a bit more investigation, seems to depend where you put it: at the end of server_args, doesn't work, after the -once, it does. Possibly there's some order of processing arguments?

    Also, it seems that I need to have a keyboard and mouse plugged into the headless box or, again, no login screen. Do you find the same?

    I'm a novice on this, s/w developer, but almost never on Linux (embedded and Windows). Only installed Ubuntu for the first time on Friday, so your guide was dead useful!

  7. There may be some order that the options need to be in, but the manual doesn't mention any, did the geometry option show up as the name of the VNC desktop?

    The server is physically an old laptop with a broken screen so I don't know if this configuration works completely headless, though it should since the only displays on the display manager are virtual. I have set up a headless box in the past using another XDM on Gentoo, so it is possible.

  8. hi... previous your solution works fine with fresh Ubuntu10.10, but some how after some updates it does not work anymore. The VNC still able to prompt userId and password, but after entering password... the VNC shutdown.
    Error log below:

    Thu May 19 08:52:37 2011 xdm info (pid 2578): sourcing /etc/X11/xdm/Xsetup
    Thu May 19 08:52:49 2011 xdm info (pid 2578): sourcing /etc/X11/xdm/Xstartup
    Thu May 19 08:52:49 2011 xdm info (pid 2595): executing session /etc/X11/xdm/Xsession
    Thu May 19 08:52:49 2011 xdm info (pid 2578): sourcing /etc/X11/xdm/Xreset
    Thu May 19 08:52:49 2011 xdm error (pid 2578): cannot remove process ID file /var/run/ Permission denied

  9. I noticed this is no longer working on the server where it was set up. When I get it working again I will post an update.

  10. Interestingly, on an installation with all the updates already done, this guide still works.

    And on the system I had where it stopped working, it is working again.

    1. Question, why doesn't this look like a normal Ubuntu desktop when I log in? All the panels are an ugly bright gray color instead of the normal charcoal..

    2. I saw a normal desktop when I did it, and didn't notice any color differences when I was using it in the past.

    3. Don't get me wrong, it's a great write-up. I'm guessing it's because your guide incorporates xdm, rather than gdm, and the ubu window manager isn't displaying correctly because of it. Then again, I'm still on 10.04 and not 10.10, but this is the closest guide, so far, for what I hope to accomplish. I'm trying to get it to where my girl can be on her login, physically, but I can still login to my desktop, remotely, at the same time so I can work on my android developer stuff. Thanks for a good guide to start with! :-)

    4. The situation you are describing is something that the VNC server without any extra setup can usually handle, with the added advantage of being able to disconnect and reconnect to the same session. If you start up a VNC server with plenty of color and get the session initiation script to start the right desktop it should just work without any of this guide.

  11. Perfect. Someone had this solution posted _nearly_ correctly at another site, and it didn't quite work. Thanks!

  12. Perfect! Other guides didn't work for one reason or another...