DEV Community

Cover image for RDP via SSH (PuTTY)
Adam K Dean
Adam K Dean

Posted on

1 1

RDP via SSH (PuTTY)

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/
Enter fullscreen mode Exit fullscreen mode

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

putty.exe -L <localport>:<remotehost>:<remoteport> <sshserver>
Enter fullscreen mode Exit fullscreen mode

For example:

putty.exe -L 8001:192.168.1.2:3389 adamkdean.co.uk
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay