A database sits on a private subnet. A developer needs to inspect it from a laptop at home. Opening the database port to the internet would invite scanning and brute-force attempts within hours, yet the work still has to get done.
Situations like this explain why Secure Shell, originally built for remote logins, ended up doing far more than opening terminals. Its ability to carry other traffic inside an encrypted connection turned it into a general-purpose plumbing tool for engineers. This explainer covers how tunneling works, the three forwarding modes, practical uses, the security trade-offs that come with them, and the cases where another approach serves better.
A Private Port and a Remote Laptop
Most internal services are deliberately unreachable from the public internet. A PostgreSQL instance listens on a private address, an internal admin panel answers only to the corporate network, and a staging server sits behind a firewall that allows a single inbound port. Those restrictions are sensible, and they also create friction the moment someone has to debug production data from outside the perimeter.
The usual shortcuts are poor ones. Opening the database port to the world exposes it to constant automated probing. Copying data to a laptop creates compliance headaches. Standing up a full VPN for one engineer’s one-off task is slow and often disproportionate. A tunnel offers a narrower path: one specific port, one authenticated user, one encrypted channel.
The idea works because most organizations already run SSH on at least one reachable host, commonly a bastion or jump server. If that host can see the private service, an engineer who can log into the bastion can borrow its network position. Traffic enters the encrypted SSH session on the laptop, travels to the bastion, and is delivered to the private service from there. Nothing new has to be opened in the firewall, which is a large part of why the technique became so common among operations teams.
Defining the Tunnel: Encapsulation Over an Authenticated Channel
A common first question is what is an SSH tunnel, and the short answer is that it is an encrypted connection used to carry some other network traffic. The SSH protocol authenticates both ends, negotiates encryption keys, and then multiplexes data over a single TCP connection. Port forwarding takes advantage of that multiplexing by assigning extra channels to arbitrary traffic, so a connection to a database, web app, or message queue rides inside the same protected session that would otherwise carry a shell.
Three components are involved in every tunnel. The SSH client starts the connection, the SSH server accepts it, and a forwarding rule describes which ports and addresses get linked. The rule decides what enters the tunnel and where it exits. Applications on either end generally have no idea anything unusual is happening. A database client simply connects to a port on localhost and gets a normal response.
Encryption protects the hop between the two SSH endpoints only. The final leg, from the SSH server to the private service, travels in whatever form the service uses, which may well be plaintext on a trusted internal network. Engineers sometimes overlook that detail and assume the entire path is protected end to end. It is not, and the distinction matters when deciding which sensitive traffic is acceptable to send through a tunnel.
Local and Remote Forwarding in Practice
With the answer to “what is an ssh tunnel” in mind, the forwarding modes are easier to distinguish by the direction in which they open a door.
Local forwarding opens a listening port on the client machine and sends whatever arrives there to a destination reachable from the server. The command ssh -L 5433:db.internal:5432 user@bastion makes port 5433 on the laptop behave like the private database. Connecting a SQL client to localhost:5433 then reaches db.internal through the bastion. The destination only needs to be visible to the bastion, not to the engineer.
Remote forwarding reverses the direction. The listening port appears on the server, and traffic is sent back to something reachable from the client. A developer who runs ssh -R 8080:localhost:3000 user@public-host exposes a local web app on port 8080 of the public host, which is handy for demonstrating a webhook integration without deploying anything. By default the remote port binds only to the loopback interface of the server. Making it reachable from other machines requires the GatewayPorts setting, a change that deserves caution because it effectively publishes a service running on a laptop.
Both modes share a useful property: they are scoped to specific host and port pairs. That narrowness is the main reason they remain popular in places where broader network access would face resistance during a security review.
Dynamic Forwarding and the Jobs Tunnels Actually Do
Dynamic forwarding drops the fixed destination. Running ssh -D 1080 user@bastion starts a SOCKS proxy on local port 1080, and any application configured to use it can reach whichever host and port it requests, resolved from the server’s side of the network. A browser pointed at that proxy sees internal dashboards as if the engineer were seated in the office. The flexibility is convenient, and it also means one tunnel can reach many systems, so it deserves tighter oversight than a single-destination forward.
Real usage tends to cluster around a handful of patterns:
- Reaching a private database or cache for debugging without exposing its port
- Wrapping a legacy protocol that lacks encryption, such as an old admin interface
- Showing a local development server to a colleague or a webhook provider
- Browsing internal-only web tools from a remote location through a SOCKS proxy
- Passing through a bastion to reach a host in another network segment
None of these are exotic. Site reliability engineers lean on them during incidents, when speed matters and a formal access request would take too long. Data engineers use them to connect desktop tools to warehouses sitting inside private networks. The pattern is the same each time: a small, temporary hole, created on demand, that disappears when the session ends. Because the tunnel lives only as long as the SSH process, forgetting to close one is the main way a temporary convenience turns into a lingering exposure.
Security Trade-offs and When Another Approach Fits Better
Tunnels are powerful because they bypass network controls by design, which is also why security teams treat them warily. A forwarded port can carry traffic that a firewall never sees as anything beyond an encrypted SSH stream, so intrusion detection tools lose visibility. An attacker holding a stolen private key can pivot from a bastion into internal systems far more easily than a firewall rule set would otherwise allow. Unmanaged keys, shared accounts, and forgotten reverse tunnels left running on servers are the usual culprits in real incidents.
Server-side settings narrow that exposure. AllowTcpForwarding can be disabled for accounts that have no need for it, PermitOpen restricts which destinations a user may reach, and GatewayPorts should remain off unless a specific requirement says otherwise. Logging connection events and pairing keys with short lifetimes or certificates limits how long a leaked credential stays useful.
Tunnels also stop making sense beyond a certain scale. Forwarding TCP traffic inside a TCP connection can behave badly on lossy links, since retransmission happens at two layers. Long-lived tunnels need keepalive handling and tend to break when networks change. Manual port mapping becomes tedious across dozens of services and engineers.
Alternatives are worth weighing once usage becomes routine. A VPN suits broad, continuous network access for large groups. An identity-aware proxy or zero-trust access gateway authenticates each request against policy and records sessions centrally, which handles the audit gap tunnels leave. For simple multi-hop shell access, ProxyJump gives a cleaner and more auditable path than hand-built forwards. Teams in cloud environments can also use provider-native session tools that avoid open inbound ports altogether.
Key Takeaways
SSH tunneling turns an ordinary authenticated connection into a flexible carrier for other traffic. Local forwarding brings a remote service to the laptop, remote forwarding sends a laptop service outward, and dynamic forwarding provides a SOCKS proxy for many destinations. Each mode solves a legitimate access problem with minimal firewall changes.
The same flexibility calls for discipline. Restrict forwarding per account, keep credentials short-lived, log activity, and treat tunnels as a temporary tool rather than permanent infrastructure. When usage grows beyond a handful of engineers and services, a managed access layer will usually prove easier to govern.
More iDevice Central Guides
- iOS 17 Jailbreak RELEASED! How to Jailbreak iOS 17 with PaleRa1n
- How to Jailbreak iOS 18.0 – iOS 18.2.1 / iOS 18.3 With Tweaks
- Download iRemovalRa1n Jailbreak (CheckRa1n for Windows)
- Dopamine Jailbreak (Fugu15 Max) Release Is Coming Soon for iOS 15.0 – 15.4.1 A12+
- Cowabunga Lite For iOS 16.2 – 16.4 Released in Beta! Install Tweaks and Themes Without Jailbreak
- Fugu15 Max Jailbreak: All Confirmed Working Rootless Tweaks List
- iOS 14.0 – 16.1.2 – All MacDirtyCow Tools IPAs
- iOS Jailbreak Tools for All iOS Versions
