In previous post I wrote about how to secure communication between Linux and Windows machine with SSH. Now in this post I am going to show you how to control Linux (Ubuntu, Debian or any other distribution) Desktop from Windows over secure connection in a very simple and elegant way using just open source software. We are going to use VNC. VNC stands for Virtual Network Computing and it is a Graphical Desktop Sharing System that uses the Remote Frame Buffer Protocol (RFB) to remotely control another computer. It transfers the keyboard and mouse events from one computer to another and returns the graphical screen updates back to the client computer over a network. VNC is platform independent technology. There are clients and servers for different Operating Systems even including Java servers and clients. Multiple VNC clients may connect to a VNC server at the same time.

First let’s install VNC server. Obviously you need some Linux computer running a desktop software such as GNOME, KDE, XFC or any other. There are couple of VNC servers available for Linux, but we are going to use x11vnc. To install it just type:

sudo apt-get install x11vnc

Next step is to obtain software for Windows. You need PuTTY. We are going to use PuTTY to secure communication between server (Linux) and client (Windows). So download putty.exe from this link and place it in some directory. It does not need installation.

Next piece of software that we need is VNC client. There are couple of VNC clients. Most of them are commercial but free for non-commercial use. We are going to use TightVNC which is dual licensed. It has GNU GPL2 and commercial license. Also they have Java version. But in our case we are going to use native Windows binary. So go to download page and get 64 or 32 bit MSI installer package. During installation process select Custom Setup and install only VNC Client.

Next step is to run and connect to Linux via PuTTY. Follow those steps to perform secure connection to Linux.

  1. Start PuTTY.
  2. Go to Connection -> SSH -> Tunnels.
  3. In field Source port enter 5900.
  4. In field Destination enter localhost:5900.
  5. Click Add button.

At the end should look something like that:

VNC Windows To Linux Desktop Connection

Then navigate to PuTTY main window and enter IP or host to which you want to connect and hit Open button.

Windows VNC To Linux Connection

Login to Linux computer by using your name and password. Then type the following commands. Note that -auth output from first command is passed as parameter to the second one. You need to find the authentication file of your login manager. In this example I am using SLiM which stands for Simple Login Manager and it is really slim and light. But if you are using GDM or KDM then authentication file will be different. So see what is output after -auth and copy & paste it in the command that runs x11vnc.

debianhowto@debian:~$ ps wwwaux | grep auth
root      6106  0.0  0.3  42652 12332 tty7     Ss+  Oct19   0:00 /usr/bin/X11/X -nolisten tcp -auth /var/run/slim.auth vt07
1002     25390  0.0  0.0   5252   784 pts/0    S+   16:25   0:00 grep auth
debianhowto@debian:~$ sudo x11vnc -safer -localhost -nopw -once -display :0 -auth /var/run/slim.auth

For more info look into screenshot:

Windows To Linux Remote Desktop Connection

Finally you should see something like this:

VNC Linux Remote Desktop

Final step is to run TightVNC Viewer and to connect. When you start TightVNC just enter localhost in the field Remote Host and hit the Connect button.

TightVNC Windows To Linux Remote Desktop Connection

If everything went normal you should see login screen of your Linux machine. Just type your user name and password to establish remote desktop session.

Linux Remote Desktop Connection via VNC and SSH tuneling