Adam K Dean

RDP via SSH (PuTTY)

Published on 5 February 2014 at 08:53 by Adam

If you're like me, and you're paranoid about opening up access to your servers to the internet, you might sometimes find yourself needing to access them but not being on the local network. A handy trick to circumvent this, if you have access to SSH, is to open a tunnel.

For this we're going to need:

  • The IP or hostname and port of the destination server (for this they are 192.168.1.2 and 3389)
  • Access to a server with SSH on the local network
  • PuTTY on your local machine

First, open up either command prompt, or MinGW or something, and navigate to your PuTTY path:

cd /c/PuTTY/

Then connect to the SSH server specifying a tunnel like so:

putty.exe -L <localport>:<remotehost>:<remoteport> <sshserver>

For example:

putty.exe -L 8001:192.168.1.2:3389 adamkdean.co.uk

This will open up a PuTTY window. Authenticate and open up another cmd/mingw prompt. In this one we're now going to use mstsc (remote desktop) to connect through the tunnel. We opened up port 8001 on our local machine, so lets connect to that.

mstsc -v localhost:8001

If you've done everything right, you should now get a remote desktop prompt.

Update from 11/02/2016: You can tunnel connections with regular ssh like so:

ssh user@hostname -L <localport>:<host>:<remoteport> -N

-L is for your tunnel, and -N is no command executed on connect.



This post was first published on 5 February 2014 at 08:53. It was filed under archive with tags linux, rdp, ssh, windows.