SSH RDP Tunnel and Port Connection

connectionportrdpssh

Tried doing some research but can't really figure out the solution (or how to troubleshoot further) for this problem.

Objective and Reasoning for setting this up:
SSH Tunnel RDP from work to home computer. At work, most ports are blocked, but I am able to use SSH.

Set-Up:
Macbook Pro (at Work) –> Internet –> HomeModem –> SSHserver and Windows 10 Pro

I am able to connect directly to Windows 10 (from a friends house or local lan) without any issues. When I connect from WAN (not at work) I have port forwarding on my router at home setup for 338900 –> 3389 Windows 10 and 22 –> 22 SSHserver

I am able to connect to my SSHserver (Debian 8) from work and everywhere without any issues.

Attempts:
From my mac I have tried:

ssh -p 22 -L 3400:192.168.1.2:3389 root@WANIP | RDP: 192.168.1.2:3400 = no connection

ssh -p 22 -L 3400:192.168.1.2:338900 root@WANIP | RDP: 192.168.1.2:3400 = no connection

ssh -p 22 -L 3400:WANIP:338900 root@WANIP | RDP: WANIP:3400 = no connection

All these attempts have been made from a WAN connection where I can just connect using: RDP WANIP:338900 = connection

Any direction and help is greatly appreciated.

Best Answer

ssh -p 22 -L 3400:192.168.1.2:3389 root@WANIP

it's a correct command. I just checked in my environment. I have used the following command to create ssh tunnel

# ssh -L 192.168.1.6:3389:192.168.88.176:3389 alex@WAN.IP -p 2222
# netstat -an | grep 3389
tcp        0      0 192.168.1.6:3389            0.0.0.0:*                   LISTEN

After that I'm able to connect to 192.168.1.6:3389 via RDP.

On Debian you should check file /etc/ssh/sshd_config. There could be some restrictions

Match User alex
    X11Forwarding no
    AllowTcpForwarding no

On your mac you should check /etc/ssh/ssh_config for the same restrictions.