Windows laptop to remote Windows PC over SSH / RDP

1 minute read

Related: Linux to Windows PC over SSH / RDP


Assume: Windows laptop connecting to a remote Windows PC with SSH server.

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)

This can be accomplished two ways, using EITHER Cygwin or Windows Subsystem for Linux on your laptop.

Cygwin

  1. Cygwin: create script file ~/myrdp.sh:
    #!/bin/sh
    
    ssh -f -p 22 -L 3391:localhost:3389 [email protected] sleep 2;
    
    mstsc /v:localhost:3391
    
  2. Cygwin:
    chmod +x ~/myrdp.sh
    
  3. Windows command prompt: create a desktop shortcut to:
    C:/cygwin64/bin/mintty.exe -e /bin/sh -l -c '$HOME/myrdp.sh'
    

Usage

Double clicking that Windows shortcut automatically:

  1. launches Cygwin
  2. makes the SSH connection (you’ll be prompted for SSH password, or use a public key file)
  3. 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.

Windows Subsystem for Linux

  1. install X11 for WSL
  2. configure laptop WSL to Windows PC over SSH / RDP.

Tags:

Categories:

Updated:

Leave a Comment