Connect local port to server port
An SSH tunnel creates a connection between a port
on your local machine and a address + port
on the server, and tunnels the data to the server over SSH on port 22 to the server address + port
.
This is done so that it doesn't get blocked by any firewalls or security groups (assuming only SSH connections are allowed to the server). After the data reaches the SSH server it gets forwarded to the address + port
you specified when you created the SSH tunnel.
An important detail here is that the destination address + port
are accessed from the context of the server, so localhost
or 127.0.0.1
refer to the server machine on the destination side of the tunnel, not your local machine.