Windows laptop to remote Windows SSH + RDP

Assumes: Windows laptop connecting to a remote Windows PC with OpenSSH server and client built into Windows.

Remote PC IP Remote PC SSH port Remote PC RDP port
1.2.3.4 22 (open TCP firewall) 3389 (blocked by remote PC firewall)

Setup: on the Windows laptop, create script file sshrdp.bat:

start /b ssh -L 3391:localhost:3389 %1

@echo off
REM enough time to enter password
timeout /nobreak 10

mstsc /v:localhost:3391

Usage: from that directory, type sshrdp myhostname to connect RDP over SSH to myhostname computer that’s setup in your ~/.ssh/config file or via the IP address or hostname directly.

sshrdp.bat:

  1. makes the SSH connection (you’ll be prompted for SSH password, or use a public key file)
  2. makes the RDP connection over the SSH tunnel (where you will be prompted for the Windows password).

Notes

You can specify some Remote Desktop parameters on the MSTSC command line. There are many more options only available via saving an .RDP profile file.

You can create an .RDP file by saving a Remote Desktop Connection and then load that specific profile by:

mstsc "c:/MyPC.RDP" /v:localhost:3391
  • use Port 3391 for local forwarding because Windows uses Port 3390 for something else.

Related: Linux to Windows PC over SSH / RDP