RDP via SSH tunnel
Introduction
The goal is to securely connect to the server behind the router from an external network.
Make sure you understand how to create the simplest SSH tunnel, for example, such as here
Creating a tunnel is a rather time-consuming task, consisting of conditionally six parts.
- Setting up an SSH server
- Setting up SSH client
- Port transfer on the router
- Opening of the session by the client
- Setting up RDP on the server
- RDP connection with the client
You will need a router, putty and freesshd.
The router must support Port Forwarding You can buy online in stores:
1. Setting up an SSH server
1.01 Install and launch freeSSHd. Create a key so that the server does not swear, then change it to a new key.
Creation of the key
1.02) There are nuances here, at the moment I prefer to choose.No."
System Service
1.03) The freeSSHd icon appears in the tray, select Settings
1.04) Of course, you need to give permission to the firewall.
1.05) In the Authentication section, allow only key access
1.06) Go to the Users menu
1.07) Add a new user
1.08) View after addition
1.09) Run it on the server. PuTTYgen
1.10) Generate a pair of keys
1.11 The public key that will remain on the server must be copied from the top window.
1.12) Insert the public key in the text editor, check that it was in one line and began with the word ssh-rsa
1.13) To save the key as a text file, the name must be the same as the user who was previously created (in our case sini).
1.14) Remove the extension
1.15) Agree.
1.16) Show me. freeSSHd keyway
1.17) Save the private key, which will then need to be transferred to the client computer As a result of previous manipulations, we have a running SSH server and a pair of keys.
2. SSH configuration on the client computer
2.18) On the client computer, you need to put the private key in a folder previously created for it.
2.19) On the client, we run PuTTY and create a connection called sini. In the Host Name (or IP address) field, we specify the desired external ip server, since it is behind the router, it will be the ip router. We change port to 443 or something else, only meaningfully.
2.20) In the Auth field, indicate the path to the private key
2.21) Select the key
2.22) Building a tunnel
port
3389 This is a standard port for RDP. We will use port 3391 on the client as
the «entrance» to the tunnel.
The image below shows what we put in line.
Local port 3391 port 3389 on IP 192.168.0. 101
2.23) Remain the session. In the Not Name field, write the IP server.
At this stage, we have prepared an SSH connection, which the server listens to on 443 ports.
Just in case, I specify that in this example, the IP server in the local network 192.168.0. 101
The external IP server is the IP router. In the picture it is smeared, in your case it will be yours.
external
IP, which is like 78.47. 141.187
Port transfer on the router
3.20) Set the link on the router MAC server address to an IP address
3.21) We explain to the router that when there is a request for port 443, you need to transfer it to the server. (Do Port Forwarding - Port forwarding)
Putty on the client
4.22) Opening of the session
Setting up RDP - On the server
5.23) Create a user sini
5.24) We must create a password.
5.25) Allow access by RDP
5.27) Add Blue to the list of RDP users
Setting up RDP - On the client
6.28) Start on the mstsc client (first you need to open the SSH tunnel).
If it is open, check whether the session is over.
To prevent anyone from working, you can check if someone is connected.
To the computer or not. This can be done with the help of
PSTools
instruction
here
6.29) Connect to localhost:3391
Enter the password.
6.30) We agree.
Note for OpenBSD
|
We have a computer in St. Petersburg (PC SPb), a server on OpenBSD in MSK (SRV MSK) and a local computer,
connected to the server in MSC (PC MSK). The goal is to connect with PC SPb to PC MSK
via ssh tunnel via rdp using putty from Windows. |
You need to do the same as described in the link, but in the first picture note
Local ports accept connections from other hosts
The source port can be selected by any of the free ones, such as 6789. In the field Destination point out
Local ip PC MSK:3389
When connecting by RDP (last picture) you can specify
127.0.0.2:6789
Article author: Andrei Olegovich
| RDP: Remote desktop | |
| SSH tunnel for RDP | |
| Network |