'

RDP inside a SSH tunnel.

June 2nd, 2014 by Andrea Matesi 2153 Views

I'm gonna post some infos on how once I did gain access to my Windows rig at home by using the RDP protocol inside a secure shell tunnel, FROM my office workstation TO my home computer!

What's the point of this? Since the RDP protocol does not encrypt traffic by default, it can be easily captured and analyzed, instead SSH encrypts everything it transports and no protocol analyzer can identify what's being transported by it.

First and foremost, the PCs involved in such a technique are the followings:

  1. My Windows XP gaming rig at home (which from now on I'll refer to as "gaming").
  2. My Ubuntu Home Server (server), connected at the same gaming lan at home.
  3. My Ubuntu Desktop Workstation at work (workstation).

There is also my home-router in between, a standard, browser configurable appliance (you mat have to configure the one given to you by your provider, YMMV).

My gaming rig was a PC with a powerful GFX card and a standard install of Windows XP; its firewall was disabled and it was directly connected with a hand made cat.5E cable to my 8 ports Gigabit Ethernet Switch.

My server was a standard low end PC with a bare install of Ubuntu 8.04 Server flavour sitting near my gaming rig. By bare install, I mean that, while installing the OS, I deselected all the features and services. I choose just the useful bare minimum to obtain a booting system. When booted, this system did offer only some vtys. This host was also directly connected to my home switch.

The other appliance I had was a browser-managed router. This router, on one side was connected to my Switch (with local IP Address), on the other side it was connected to the Internet via my ISP ADSL. I had an always-on account.

The internet browsing was automatic since the router was configured according to my ISP settings.

What I wanted to accomplish was to gain RDP access to my gaming rig from the office.

There were 2 different networks involved:

  1. My Home Network.
  2. The Office Network.

The Home LAN was the classic home network, 192.168.0.0/24

gaming's IP was 192.168.0.3

server's IP was 192.168.0.2

home-router IP was 192.168.0.1 inside and ISP-offered public IP address outside (knowing this address was crucial).

The PCs inside my home network were all able to ping each other and no firewall was enabled.

the next step consisted accessing the

server

and installing on it the ssh server service daemon.

For the sake of simplicity, I took Ubuntu 8.04 Server and manually installed OpenSSH:

  • apt-get install ssh

I then used the default options by simply pressing Return.

The next thing I needed was to configure port forwarding on my router, so, from my gaming rig I pointed my browser to 192.168.0.1 and, after inserting the right credentials (router's user name and password), I went to a page referring to as "port forwarding".

On the port forwarding section I made a custom rule that pointed port 22 to my internal home server, with this custom rule:

  • All the Inbound connections relevant to port 22 from the Internet to my router, should be sent to port 22, to my internal server IP address 192.168.0.3.

I took note of the public IP address of my router, you can simply go to www.whatismyip.com and read what your public IP address is (at the time, mine was something like 72.16.125.23 and it always changed because it was a public dynamic address) or you may decide to use a service like dynDNS.

Another thing to take care of is to set your home-router to respond to ping requests coming from the Internet, so find the right page and set it to respond to pings, because i found I had problems by not enabling this.

Back at the office I had a standard pc, wich I'm referring to as my workstation; Workstation was able to access the Internet similarly to my home gaming rig scenario.

First thing first, I tried to ping my home router's public dynamic IP address:

  • ping 72.16.125.23

If you receive your responses, then you are halfway to doing this.

The next thing I tested was the SSH connectivity to my ubuntu server, so I simply did:

  • ssh yourconfiguredserveruser@72.16.125.23

If you received a prompt asking for a password, then you configured it correctly: the ssh home server is responding and you are allowed to access it.

This also means that the forwarding rule previously applied to your home router functioned correctly.

Now just take a break and experiment with it: you're at your home server!

Since your server is inside your home network, making a tunnel is just a matter of sending him the right commands.

The magic of all this lies in the ssh server capability to stream all the data between your PC (my workstation in this case), to another PC inside your home LAN, not by accessing it directly, but by using the server as a BRIDGE that links you to the other computers inside the lan.

Open a terminal (or PuTTY if you have Windows in place of a linux workstation), and write the following:

  • ssh -L 3389:gaming's-IP:3389 srvusr@Internet-router'sIP

You'll be asked for a password; insert your home server's password and, if you receive a shell, you're done!

Now, from workstation, open up an RDP client (like the Remote Desktop or a free alternative) and simply connect to localhost. You should be able to receive the Remote Desktop session of your gaming rig :D

At this point it is just a matter of inserting the right credentials to access Windows XP and you're done: a relatively fast and secure way to remotely control your home desktop gaming rig: too bad videogames streaming wasn't still possible by using only free/Open Source alternatives (for proprietary ones, there seems there are for-pay solutions like stream my game that seem to work somehow, but I haven't tried and tested those kind of services yet).

Posted in Tips and Tricks. | Comments Off on RDP inside a SSH tunnel.

Comments are closed.