SSH tunnels are useful to cross insecure networks, leveraging end toproviding end-to-end encryption, when connecting two end-points points that seatsseat on distinct trusted networks.
EDITED
- A local host-A: your
localhost, on your local network (likely behind firewall/NAT)A local host-A: your
localhost, on your local network (likely behind firewall/NAT) - A publicly reachable host-B: the
awsserverA publicly reachable host-B: the
awsserver - A non-publicly reachable host-C: on the restricted remote network (likely behind firewall/NAT)
A non-publicly reachable host-C: on the restricted remote network (likely behind firewall/NAT)
- A non-publicly reachable host-D: the one you refer to as
deviceIP, that listens on port80and is on the remote restricted networkA non-publicly reachable host-D: the one you refer to as
deviceIP, that listens on port80and is on the remote restricted network
- A tunnel from host-A to host-B, that:
A tunnel from host-A to host-B, that:
Lets host-A listen on port
8080Sends traffic from that port through the tunnel
On host-B (
aws), redirects the traffic coming from the tunnel to the local (i.e. on host-B) port15872(I took it from your comments; you can choose any available port; just make sure to use the same one in all commands)
# Execute on host-A $ ssh -L 8080:localhost:15872 user@host-B A tunnel from host-C to host-B, that:
Lets host-B listen on port
15872Sends traffic from that port through the tunnel
On host-C (your Linux server), redirects that traffic to port
80on host-D
# Execute on host-C $ ssh -R *:15872:host-D:80 user@host-B
- Lets host-A listen on port
8080 - Sends traffic from that port through the tunnel
- On host-B (
aws), redirects the traffic coming from the tunnel to the local (i.e. on host-B) port15872(I took it from your comments; you can choose any available port; just ensure it be the same in all commands)
# Execute on host-A $ ssh -L 8080:localhost:15872 user@host-B - A tunnel from host-C to host-B, that:
- Lets host-B listen on port
15872 - Sends traffic from that port through the tunnel
- On host-C (your linux server), redirects that traffic to port
80on host-D
# Execute on host-C $ ssh -R *:15872:host-D:80 user@host-B