Skip to main content

SSH tunneling

· One min read
Hreniuc Cristian-Alexandru

Let's say we have this diagram of servers:

A:9104 -> B -> C:9104

Connect from server A to server C via server B:

# We are here on server A and we run the following command:
ssh -N -f -L \*:9104:C:9104 user@B
# -N do not run any command on remote server
# -f run in background
# -L local forward
# \* - the 9014 port will be publically visible from outside of server A

Now to access C:9104, you will be able to do it from A like this A:9104.

Why would you want to do this? When you can't access directly the server C from server A, but you can access it from server B. And from server A you can access B. Voila!