setup vnc-server on ubuntu 8.04

July 13, 2011

Objective:
To have vncserver setup with gdm on the host so that a remote vnc connection to it will be greeted with a gdm login screen for the user to login.

Clarification of terms used:
Host – refers to the PC you are trying to install vncserver on.
Remote – the PC that is going to connect to the host

1. Get required packages installed
On the host, run
Code:

sudo apt-get install vnc4server xinetd

Being a server guy, I prefer to ssh into the host and do all the work, so I also
Code:

sudo apt-get install openssh-server

This way I can directly test the vnc by using vncclient on my remote desktop to the host.
Of course if you have only a host PC, then you may also need a vncclient to test it.

2. Enable XDMCP
This is the part that is responsible for bring up the gdm login.

Code:

sudo vi /etc/gdm/gdm.conf

Uncomment this line
Code:

RemoteGreeter=/usr/lib/gdm/gdmlogin

Enable xdmcp, look for [xdmcp] and change Enable to true.
Code:

[xdmcp]
Enable=true

Restart gdm,
Code:

sudo /etc/init.d/gdm restart

3. Setup xinetd
Create a new service file for xinetd
Code:

sudo vi /etc/xinetd.d/Xvnc

(vi is of course one of many editors you can use)

Paste the following into the file and save:
Code:

service Xvnc
{
type = UNLISTED
disable = no
socket_type = stream
protocol = tcp
wait = no
user = nobody
only_from = localhost
server = /usr/bin/Xvnc
server_args = -inetd -query localhost -geometry 1024×768 -depth 16 -cc 3 -once -SecurityTypes=none -extension XFIXES
port = 5901
}

Restart xinetd
Code:

sudo /etc/init.d/xinetd restart

4. Connect from remote
Because I added only_from = localhost in /etc/xinetd.d/Xvnc above, I will need to ssh tunnel and forward my remote port (see term clarification above, as this is actually my local PC that I working from) to the host (this is the ‘remote’ where vncserver is being installed). If you do not need this step (why not?), just remove the line.

I use putty on Windows so just go to
Connections >SSH >Tunnels
Source Port: 5901
Destination: localhost:5901
Add
Then establish a normal ssh connection to the host or use my existing ssh connection.

This link might be helpful for those using other clients https://help.ubuntu.com/community/VNCOverSSH

I use UltraVNC, so this is what I do:
Open Viewer
VNC Server: localhost:5901
Connect

5. Done
The vnc viewer should open up and a gdm login screen presented (with a Debian logo).
Enter your username and password. That’s it.

Hopefully this do not generate 45+9 pages of discussion.

Update :
How to connect with an Ubuntu remote using vinagre (Ubuntu’s default vnc client) through an ssh tunnel