Buscar este blog

viernes, 30 de octubre de 2015

VNC Connection with SSH Tunnel

In a previous post I explained how to make a remote desktop connection using a SSH Tunnel. Recently I had to use this solution and I found it did not work with the target machine´s network configuration. Fortunately there Mr V (alias coffee man) was to safe our lives.

This new solution involve Real VNC and, of course, a SSH Tunnel.

As you can check in the official site (http://www.realvnc.com/download/):
VNC enables you to remotely access and control your devices wherever you are in the world, whenever you need to. VNC has a widespread user base — from individuals to the world's largest multi-national companies — utilizing the technology for a range of applications.
You will need two tools:
  • VNC Server installed in the Target PC
  • VNC Viewer "installed" (there is a portable version) in the Source PC
Also you will need a third machine, called Gateway, with a SSH Server installed.


Previous preparation

I will not explain again how to set up a SSH server in Gateway. In this case, I will use a CentOS machine, so this step is already taken for granted.

In Target machine you do need to install VNC Server. You can install only the VNC Server and leave the VNC Viewer because in Target PC you will not need it.



The installation is quite simple and you can leave all options by default. You only need to set a connection password.


Once installed, the first time you start the program, it will ask you for a license key. You can get a free non-expired license in the official site.





The important part of all of this configuration is the port 5900. This is the port in which VNC Server will be listening for incoming connections.

Tunneling

There will be just one SSH Tunnels:
  • From Target PC to Gateway
The topology of the solution is depicted in the following image:



Tunnel from Target to Gateway

Working on Target PC, with putty you have to set the following configuration.
In Session category:
  • Host name and port of the SSH Server of Gateway
In Connection category:
  • Set the parametter "Seconds beween keepalives" to 180
In Connection > SSH > Tunnels category:
  • Check "Local ports accept connections from other hosts" option
  • Check "Remote ports do the seame (SSH-2 only)" option
  • Set Source port 9999 (this is a random number), destination localhost:5900 and check the option Remote. Then push "Add"
Note; If with localhost does not work, try to put the Target PC IP in destination.




Testing the tunnel

In order to test de connection, from Source, you need to install VNC Viewer. This is a standalone app (ie, portable).

In Source PC just open VNC Viewer and set the value of VNC Server as your Gateway direction and port 9999.


Then you will have to enter the password you set during the VNC Server installation.


Enjoy.

No hay comentarios:

Publicar un comentario