SSH Tunnel for RDP use!

So, let’s say, for example, that your desktop (PC1) can’t RDP directly out to the internet, but you do have access to a Linux system (Linux 1) in another part of the network that can? And to make things more exciting, the machine you want to RDP into (HomePC) is on a remote network with no direct access to it, but it too is on a network that has a Linux box (Linux 2) with SSH access!

You can achieve this by creating SSH tunnels through the Linux systems. Here are the steps:

  1. Create an SSH tunnel from PC1 to Linux 1:
    Open a command prompt on PC1 and run the following command:
   ssh -L 9999:localhost:9999 user@Linux1

Replace user with your username on Linux 1. This command creates a tunnel from PC1 to Linux 1, forwarding port 9999 on PC1 to port 9999 on Linux 1.

  1. Create an SSH tunnel from Linux 1 to Linux 2:
    On Linux 1, run the following command:
   ssh -L 9999:localhost:9999 user@Linux2

Replace user with your username on Linux 2. This command creates a tunnel from Linux 1 to Linux 2, forwarding port 9999 on Linux 1 to port 9999 on Linux 2.

  1. Create an SSH tunnel from Linux 2 to HomePC:
    On Linux 2, run the following command:
   ssh -L 9999:localhost:3389 user@HomePC

Replace user with your username on HomePC. This command creates a tunnel from Linux 2 to HomePC, forwarding port 9999 on Linux 2 to port 3389 on HomePC (the default RDP port).

  1. Connect to the RDP session:
    Now, you can start an RDP session from PC1 to HomePC by connecting to localhost:9999. The connection will be forwarded through the SSH tunnels to HomePC.

Please note that you need to keep all the SSH sessions open during the RDP session. If you close any of them, the tunnel will be closed and the RDP session will be disconnected. Also, make sure that SSH service is running and accessible on all the Linux systems.