External IP using VDS by creating an SSH tunnel


External IP using VDS by creating an SSH tunnel

External IP using VDS by creating an SSH tunnel


In this article, we will talk about creating SSH tunnels. First you need to figure out what SSH tunneling is in general, and why it is needed. And that's why it's needed: a) You need a connection between two machines over a secure channel b) You need to use the resources of the machine (or any computer that it sees) with a gray (internal) IP from the outside, through an additional server (or VDS) that has an external (white) static IP address. c) Other situations (in general, this is all described in man ssh).

Task: Redirect all connections from the 81 TCP port of the machine (A), which has an external IP 89.89.89.89, to the 80 TCP port of the machine (B), which is located behind NAT, and has an IP 10.10.10.10 in the local network.

Decision:

Log in to (B) and execute the following command

$ ssh -R 8181:localhost:80 [email protected]

The authenticity of host '89.89.89.89 (89.89.89.89)' can't be established. DSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '89.89.89.89' (DSA) to the list of known hosts. Password:

The system will ask if you need to continue the connection -- answer it in the affirmative (yes), and enter the password of the root user (or the desired one) of the machine 89.89.89.89.

That's it, now when requested http://89.89.89.89:8181 / will open http://10.10.10.10

Actually, instead of localhost:80, you could specify any of the IP addresses that are visible to the machine on 10.10.10.10.

P.S. In order for the SSH connection not to break when closing the connection from your PC to the machine (B), you need to put this connection on the screen.

$ pkg install screen $ screen Press Enter, after performing the actions described in the article, press Ctrl + A, Ctrl+ D, write exit, and enjoy life.






Go back
6-03-2024, 10:47