Have you ever wanted to ssh to your Linux box that sits behind NAT? Now you can with reverse SSH tunneling. This document will show you step by step how to set up reverse SSH tunneling. The reverse SSH tunneling should work fine with Unix like systems.
Let’s assume that Destination’s IP is 192.168.20.83 (Linux host that you want to access).
You want to access from Linux client with IP 8.7.6.5
Destination (192.168.20.83) <- |NAT| <- Source (8.7.6.5)
- SSH from the destination to the source (with public ip/fqdn) using command below:
ssh -R 1339:localhost:22 sourceuser@8.7.6.5
* port 1339 can be any unused port.
- Now you can SSH from source to destination through SSH tuneling:
ssh destinationuser@localhost -p 1339
- 3rd party servers can also access 192.168.20.83 through Destination (8.7.6.5).
Destination (192.168.20.83) <- |NAT| <- Source (8.7.6.5) <- 3rd party server
- From 3rd party server:
ssh sourceuser@8.7.6.5
- After the sucessful login to Source:
ssh destinationuser@localhost -p 1339
* the connection between destination and source must be alive at all time.
Tip: you may run a command (e.g. watch, top) on Destination to keep the connection active.
Recent Comments