What is SSH tunneling
Tunneling used to connect two machine and access the ports from the remote machine or local machine using ssh protocol. This method is widely used in administering server infrastructure management.
What you will learn
- Connecting remote server and accessing its internal ports from local machine
- Reverse SSH tunneling - Accessing local ports from the remote server
Access remote server port form the local machine
Connect to the remote server
10.10.10.1 and try to access it's internal port
-L argument is used to connect as SSH tunnel.
ssh -L 8000:localhost:8080 [email protected]
Note: 10.10.10.1 is used for demonstrating purpose only. You should use your server IP instead.
localhost:8000 we can access the
Reverse SSH tunneling - Accessing local ports from the remote server
We have MySQL database
10.10.2.10:3306 in our on premise network which is not accessible by outside of the network. We need to connect this to web server in AWS Cloud
-R argument is used to connect as SSH reverse tunnel.
ssh -R 3306:10.10.2.10:3307 [email protected]
Note: 22.214.171.124 is used for demonstrating purpose only. You should use your server IP instead.
Now from AWS
126.96.36.199:3307 we can access the
How to forward all ports
You create simple proxy by forwarding all ports from source to destination server.
-D argument is used to forward dynamic ports.
ssh -D localhost:1337 [email protected]
SSH tunneling is simple but its very powerful, we have seen how to use ssh tunneling and reverse ssh tunneling.