Windows laptop to remote Windows PC over SSH / RDP

Related: Linux laptop to remote Windows PC over SSH / RDP

We assume a remote Windows PC with SSH Cygwin Windows 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)
  1. In Cygwin on your Windows laptop, type

    nano ~/myRDP
    

    and paste in:

    #!/bin/bash
    ssh -f -p 22 -L 3391:localhost:3389 [email protected] sleep 2;
    mstsc /v:localhost:3391
    
  2. then in Cygwin Terminal:

    chmod +x ~/myRDP
    
  3. In Windows, create a desktop shortcut to:

    C:/cygwin64/bin/mintty.exe -e /bin/bash -l -c '$HOME/myRDP'
    

Using one-click RDP over SSH tunnel

Double clicking that Windows shortcut launches Cygwin, makes the SSH connection (you’ll be prompted for SSH password, or use a public key file) and then makes the RDP connection over the SSH tunnel (where you will be prompted for the Windows password).

Configuration notes for special cases of RDP over SSH tunnel

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

Note, we used Port 3391 for the local forwarding because Windows 7 uses Port 3390 for something else.

Tags:

Categories:

Updated:

Leave a Comment