HOWTO: Set up VNC server with resumable sessions



1) Logon to your Ubuntu, select "System->Administration->Login Windows" from Menu

2) Select "Remote" tab and "Same as Local" for style.

3) Click on the "Configure XDMCP…" button at the bottom right.

4) Uncheck "Honour indirect requests"

5) Close the Login Windows Administration windows.

6) Fire up your terminal and issue "sudo vi /etc/X11/gdm/gdm.conf" or use any editor you prefer.

7) check that in the section [xdmcp] has Enable=true:
[xdmcp]
# Distributions: Ship with this off. It is never a safe thing to leave out on
# the net. Setting up /etc/hosts.allow and /etc/hosts.deny to only allow local
# access is another alternative but not the safest. Firewalling port 177 is
# the safest if you wish to have xdmcp on. Read the manual for more notes on
# the security of XDMCP.
Enable=true

8) Check that RemoteGreeter is commented:
#RemoteGreeter=/usr/lib/gdm/gdmlogin

9) Install the vnc4server and xinetd packages using "sudo apt-get install vnc4server xinetd"

10) Create the password for your VNC login using "sudo vncpasswd /root/.vncpasswd"

11) Edit /etc/xinetd.d/Xvnc file (this should be created as a new file if you haven't previously do anything) using the commend "sudo vi /etc/xinetd.d/Xvnc" and ad in as:
service Xvnc
{
type = UNLISTED
disable = no
socket_type = stream
protocol = tcp
wait = yes
user = root
server = /usr/bin/Xvnc
server_args = -inetd -query localhost -geometry 1024×768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 passwordFile=/root/.vncpasswd -extension XFIXES
port = 5900
}
P/S: You may want to change the resolution (1024×768) and color depth (-depth 16) according to your need.

12) Now is a good time to reboot your machine "sudo init 6"

13) When the Ubuntu machine is up and running, go to you Windows and use your favorite VNC client, and connect to your Ubuntu. You should be able to connect without problem.

14) Final word: As you might notice that in (7), enabling XDMCP is not something safe, you may want to configure your firewall to protect the machine properly.
=====================================================================

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/shxrdb $HOME/.Xresourcesxsetroot -solid blackgnome-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.

======================================================================
Warning!
This howto is old, unsupported, and relies on a broken package. This should be used as reference only.


So here's the complete list of steps that are required to set the VNC server that any user can login into and start a session. It is also persistent, meanning that even if you disconnect the VNC client your X session will not end (unless you explicitly log out) and you can reconnect to the same session again. The VNC server uses a separate display (:1) than your regular X server, which works with your physical display (:0). So two sessions can be active at the same time (one person sitting at the physical display and another remotely connecting using VNC).

1. Enable XDMCP
System->Administration->Login Screen Setup
Tab Security->Enable XDMCP
Tab XDMCP–> You can disable "Honor Indirect Requests"

Note: Before doing the next step, you need to make sure the extra repositories (e.g. universe) are enabled:
http://easylinux.info/wiki/Ubuntu#Ho…a_repositories

2. Install required packages (vncserver and xinetd)

Code:
sudo apt-get install vnc4server xinetd
Note to AMD64 users: The current version of vnc4server in the repositories has a bug, so you need to download and install the fixed vnc4 packages as shown below:

Code:
wget http://qt1.iq.usp.br/download/vnc4server_4.0-7.3_amd64.debwget http://qt1.iq.usp.br/download/xvnc4viewer_4.0-7.3_amd64.debsudo dpkg -i vnc4server_4.0-7.3_amd64.debsudo dpkg -i xvnc4viewer_4.0-7.3_amd64.deb

3. Set the VNC passwd
Code:
sudo vncpasswd /root/.vncpasswd
4. Add vnc service to xinetd:
Code:
sudo gedit /etc/xinetd.d/Xvnc
Enter this into the new file:

Code:
service Xvnc{        type = UNLISTED        disable = no        socket_type = stream        protocol = tcp        wait = yes        user = root        server = /usr/bin/Xvnc        server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/X11/fonts/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd        port = 5901}
5. Restart xinetd (usually there is no need to reboot, but occasionally it might be required)

Code:
sudo /etc/init.d/xinetd stopsudo killall Xvncsudo /etc/init.d/xinetd start
6. That's it! To test that this is working first try to connect from the same machine (the machine we just set up the VNC server on):

Code:
vncviewer localhost:1
You should be prompted for the VNC password, and then see the GDM login screen where you can login and start a new X session. If that works, you can now go ahead and try to connect from remote machine using your favorite VNC client (remember to first close the local vncviewer we started above). Remember to use the VNC server machine's domain name or IP address, followed by :1 (e.g. 192.168.0.100:1). If connecting locally as shown above works, but connecting remotely fails, then this means you have a problem with a firewall which is blocking some ports. See the notes below about how to deal with that.

Note about ports: The VNC server set up as shown uses TCP port 5901. If you are using firewall software (e.g. firestarter) on that machine, you need to allow incoming connections on this port. If you are using a router which assigns your machine a private address (e.g. 192.168.0.100) which is not accessible from the internet, then you need to forward TCP port 5901 from the router to this machine.

Note about security: This setup allows any user to start an X-session remotely by logging in using his regular password (after starting the VNC connection using the VNC password), so if the user disconnects without logging out, any other user which knows the VNC password can connect afterwards and resume the same session that the first user started. So if you do not want to log out before disconnecting, it's advisable to at least lock your VNC X-session screen. Also note that while a remote user is connected thru VNC, no other connection will be accepted. An idle VNC client will be disconnected after one hour, but this can be changed by using the "-IdleTimeout" option in the server_args line in /etc/xinetd.d/Xvnc. For example, you can add "-IdleTimeout 300" to change it to 5 minutes.

Tag Cloud