|
| 1 | +# RDP tunnelling over SSH |
| 2 | + |
| 3 | +RDP tunneling is a technique that relies on SSH to create a secure channel that forwards local traffic to a remote server's RDP port. The content of the local traffic in RDP tunneling includes: |
| 4 | + |
| 5 | +- User Input: Keyboard and mouse actions. |
| 6 | +- Display Data: Screen updates and graphical interface data. |
| 7 | +- Clipboard Contents: Text or files copied and pasted between the local and remote systems. |
| 8 | +- File Transfers: Transferred files if drive redirection is enabled. |
| 9 | + |
| 10 | +By setting up an SSH tunnel, a local port is forwarded to the remote server's RDP port (3389). The RDP client is then connected to `localhost:<local_port>`, ensuring that the RDP session is encrypted. |
| 11 | + |
| 12 | +## SSH Commands |
| 13 | + |
| 14 | +### Steps |
| 15 | + |
| 16 | +1. Jump host (-J): connect first to the eidf_gateway as an intermediary before reaching the target VM. Authentication is achieved using the identity file provided by the host (-i). |
| 17 | + |
| 18 | +2. Local Port Forwarding (-L): Forwards local port 12345 to localhost:3389 on the remote machine, allowing RDP access via localhost:12345. |
| 19 | + |
| 20 | +3. Configure a RDP client (for example 'Windows App') to connect to `localhost:<local_forwarded_port>` instead of directly accessing the remote machine's IP. Then connect on the remote server as 'username'. |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +Connect to eidf666 (IP address 10.24.2.224) as user u666 |
| 25 | + |
| 26 | +```sh |
| 27 | +ssh -J u666@eidf-gateway.epcc.ed.ac.uk -i ~/.ssh/eidf666-vm -o ServerAliveInterval=900 -L 39001:localhost:3389 u666@10.24.2.224 |
| 28 | +``` |
| 29 | + |
| 30 | +Defaults like PubkeyAuthentication=yes, PasswordAuthentication=yes, ForwardAgent=yes, ForwardX11=yes, and ForwardX11Trusted=yes are omitted. |
| 31 | + |
| 32 | +Once the connection is established, on Windows App or similar use pc name: `localhost:39001`. When prompted, the username will be 'u666' with corresponding password. |
| 33 | + |
| 34 | +### SSH Configuration |
| 35 | + |
| 36 | +All of the above can also be achieved adding the following to the SSH `.config` file: |
| 37 | + |
| 38 | +```sh |
| 39 | +host eidf666_gateway |
| 40 | + Hostname eidf-gateway.epcc.ed.ac.uk |
| 41 | + User u666 |
| 42 | + IdentityFile ~/.ssh/eidf666-vm |
| 43 | + |
| 44 | +host eidf666_rdp |
| 45 | + Hostname 10.24.2.224 |
| 46 | + User u666 |
| 47 | + PubKeyAuthentication yes |
| 48 | + PasswordAuthentication yes |
| 49 | + IdentityFile ~/.ssh/eidf666-vm |
| 50 | + ProxyJump eidf666_gateway |
| 51 | + ServerAliveInterval 900 |
| 52 | + ForwardAgent yes |
| 53 | + ForwardX11 yes |
| 54 | + ForwardX11Trusted yes |
| 55 | + LocalForward 39001 localhost:3389 |
| 56 | +``` |
| 57 | + |
| 58 | +Can then use the command 'ssh eidf666_rdp' to create the connection. |
0 commit comments