Skip to main content

Port Forwarding and Tunneling

Chapter 30: SSH Local Port Forwarding

In this chapter, you'll learn how SSH local port forwarding works, how to forward remote ports to your local machine, and how to use it for databases and dashboards.

In the previous chapter, you learned what SSH tunneling is, the three types of port forwarding, how tunnel commands are structured, and how to run tunnels in the background using the -fN options, which gives you the basic understanding needed to start using SSH tunnels in real production systems.

In this chapter, you'll learn about local port forwarding, which is the most commonly used type of SSH tunnel, as it allows you to securely access a service running on a remote server, or even another machine connected to that server, as if the service were running directly on your own computer, which is especially useful when the service is blocked by a firewall, only available on a private network, or not exposed to the internet.

The best part is that you do not need a VPN, firewall changes, or additional tools, because everything works through a normal SSH connection.

What SSH Local Port Forwarding Does