An Open Access Peon

20 May 2010

Ubuntu 10.04 vnc-based login server

This recipe is for setting up a VNC login server. This allows you to use a VNC client to access a full GUI on a remote server. If instead you want to get VNC access to your desktop (or share with other users) you need to enable remote desktop.

VNC connections are not encrypted so if you connect directly to the VNC server any login details will be sent in the clear.

Install the required packages:

sudo apt-get install vnc4server xinetd gdm


Restrict GDM to only listening to localhost by adding the following to /etc/hosts.allow:

gdm: ip6-localhost


Enable XDMCP in GDM by setting up /etc/gdm/custom.conf as:

# GDM configuration storage

[daemon]

[security]

[xdmcp]
Enable=true
HonorIndirect=false
# following line fixes a problem with login/logout
DisplaysPerHost=2

[greeter]

[chooser]

[debug]


Create a new xinetd service /etc/xinetd.d/Xvnc (adjust geometry to get different screen sizes):

service Xvnc
{
type = UNLISTED
disable = no
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/bin/Xvnc
server_args = -inetd -query ip6-localhost -geometry 1280x800 -depth 16 -cc 3 -once -SecurityTypes=none
port = 5901
}


Restart gdm (which will close any current logins!) and xinetd:

sudo service gdm restart
sudo /etc/init.d/xinetd restart


You can then connect to the VNC server using:

vncviewer localhost:5901

25 Comments:

  • You are a savior! I've been trying to work around the lack of XDMCP in 10.04. This is just what I needed!

    By Anonymous Anonymous, at 10:29 pm  

  • You the man (or woMAN!), had done this for 8.04 LTS and wanted to do the same for 10.04, your instruction worked perfectly!

    By Blogger PimpNinja, at 4:38 pm  

  • There's a typo in your commandline to restart GDM. It should be:
    sudo service gdm restart

    Marek

    By Anonymous Anonymous, at 4:28 pm  

  • You.. rock! Thank you!!

    By Anonymous Michelle Wright, at 12:09 pm  

  • Brilliant, thank you.

    Strange issues though! Keys all work fine when on the machine directly but via VNC certain keys activate menu options at the top. It just seems to affect the S and M keys. When you press S the menu with the power button in the top right pops up. If you press M I get the menu with the email and social networking stuff in.

    Any ideas? Thank you!
    Michelle

    By Blogger Michelle, at 12:38 pm  

  • Yea! This is the ticket. Man, it took me much too long to find this. We need to get this a higher ranking on google or something...

    By Anonymous Anonymous, at 2:53 am  

  • As with EVERY OTHER method for doing VNC on Ubuntu, this method does not permit you to modify system settings, mount drives, access sound devices, etc. Any tips on actually getting a WORKING/USABLE vnc session?

    By Anonymous Petey, at 10:13 am  

  • Thanks a million. Works well!

    By Anonymous Anonymous, at 11:36 am  

  • after connecting to server via vnc X starts, but gdm don't.. i configured it exactly to this post but service gdm restart gives me restart: Unknown instance:
    why is that?
    ubuntu lucid 10.04, 2.6.32-5-xen-amd64. it's virtual machine (domU)

    By Anonymous Anonymous, at 12:57 pm  

  • after connecting to server via vnc X starts, but gdm don't.. i configured it exactly to this post but service gdm restart gives me restart: Unknown instance:
    why is that?
    ubuntu lucid 10.04, 2.6.32-5-xen-amd64. it's virtual machine (domU)

    By Anonymous Anonymous, at 12:58 pm  

  • Wonderful!!
    Now, is there anyway to save the "session"? (So I can reconnect to the same desktop from elsewhere)

    By Blogger Unknown, at 8:57 pm  

  • Will this work for a Kubuntu 10.04 installation? Would I need to follow these directions for KDM as opposed to GDM?
    I've had a lot of issues with trying to get vnc4server to work properly under Kubuntu 10.04 Hoping this might do the trick.

    Thanks in advance,
    Linux N00b

    By Anonymous Anonymous, at 6:17 pm  

  • Thank you very much!

    DisplaysPerHost=2 was the missing piece of my puzzle. Put that in, and everything fell into place.

    By Anonymous Anonymous, at 1:36 am  

  • I cannot get this working under a XenServer PV host as GDM has no video card and thus the VNC session only display checkerboard and X cursor, any ideas?

    By Anonymous Anonymous, at 4:37 am  

  • Bless your heart!!!! I've looked through forum post after forum post and nothing was working.. This just worked and worked exactly the way I wanted too!!!!!

    By Anonymous Anonymous, at 7:34 pm  

  • Many thanks for putting together this HowTo!

    However, I keep encountering a recurring problem. The problem seems to be that VNC is not connecting to XDMCP. It may work once, then after a reboot, when I reconnect all I get is the default grey background, and gdm does not load to screen. At the local console, gdm is loaded and is awaiting login. It's almost like the VNC service is not respawning after a disconnection or reboot.

    Any idea what would cause that?

    By Anonymous Carl Vancil, at 6:49 pm  

  • Thans, but i get a grey pixeled screen.Where did i go wrong?

    By Blogger Unknown, at 4:59 pm  

  • thanks a bunch for this!
    working perfectly as others said.

    By Anonymous Anonymous, at 7:53 pm  

  • Hi,
    I am somewhat new to this so I will ask some basic questions.

    1)gdm: ip6-localhost
    How should I understand the above?
    Should I substitute something for "localhost"? ..... what

    2)/etc/gdm/custom.conf
    There is not such file should I create one?

    Thanks

    By Anonymous Anonymous, at 7:30 am  

  • Not working using TightVNC from windows box

    By Anonymous Anonymous, at 12:57 pm  

  • Same problem here, i get a grey screen with the classic x cross.

    By Blogger Unknown, at 5:09 am  

  • This works for 11.04 as well, both using ip6-localhost or simply localhost (with the latter, add 'ipv6.disable=1' without the quotes to /etc/default/grub , in the section for boot time default switches, for instance, right after quiet verbose, within the quotes on that line).

    Now, on 11.04, there's been some caveats. This works, but I'm now seeing an error stating "/usr/lib/libgconf2-4/gconf-sanity-check-2 exited with error status 256". However, once I click the dialog box, I'm not bothered by that error again until I establish a new logon session.

    Otherwise though, this all works like a champ! I took mine a step further and incorporated xrdp as an RDP listener, then set RDP's menu to choose between 3 separate scripted instances, each with a different resolution and color depth. This way, you get the best of both worlds! ;)

    By Anonymous Anonymous, at 10:26 pm  

  • This works great, but there's one thing that would be even better.

    I have this running in a VM and I would like to remove the emulated VGA card as this wastes cycles. However when I do this gdm doesn't start and vncviewer accesses just a blank X session without a window manager.

    Do you know how to set this up on a headless *and* graphics-card-less system?

    Thanks - Alex

    By Blogger Alex Zeffertt, at 10:56 am  

  • Thanks for this easy guide. Works like a charm!

    By Blogger walter, at 4:35 pm  

  • Thanks, great guide

    By Anonymous Anonymous, at 2:33 am  

Post a Comment

<< Home