Setting Up VNC Server On Ubuntu

I've started to set up a server at my house, where I eventually want to run it headless, and I can just VNC in from my other Desktop. I installed Ubuntu 10.10, setup remote desktop on the server, and from there was able to do any work remotely. That was nice. I turn the computer off at night, and the next day when I was going to work on it, I cannot VNC in anymore. One day passed, and now every time I try to use VNC it comes up with "Failed to connect to server" I also set a static IP address on the server too, so I know the address isn't changing every so often. 

I did it earlier, so I know I have it set up correctly, but when I restarted the computer, did some magical firewall get setup without my knowledge?

Solution:

The setup was done almost immediately after a fresh installation of 8.04 desktop on our office internal network.

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 xinetdBeing a server guy, I prefer to ssh into the host and do all the work, so I also 

Code:
sudo apt-get install openssh-serverThis 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.confUncomment this line

Code:
RemoteGreeter=/usr/lib/gdm/gdmloginEnable xdmcp, look for [xdmcp] and change Enable to true.

Code:
[xdmcp]
Enable=trueRestart gdm,

Code:
sudo /etc/init.d/gdm restart3. 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 1024x768  -depth 16 -cc 3 -once -SecurityTypes=none -extension XFIXES
        port = 5901
}

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.

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.

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Linux Home: Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.