# SSH Tunnel

> A way to send one more link through SSH. It reaches a private service.

**Field:** Infrastructure  
**Category:** SSH & Remote Access  
**Also known as:** SSH Port Forwarding, Local Port Forwarding, ssh -L

## Think of it like

Think of it like a secret hall between two homes. You walk through, and no one outside sees.

## Definition

An SSH tunnel carries another connection inside your SSH login. You pick a port on your own computer. Anything sent to it travels through SSH and comes out on the server's side. That lets you reach a service the server keeps private, like a database. Nothing new has to be opened to the internet.

## Example

Emma's database only works from inside her server. She opens a tunnel to it. Her laptop's app then uses port 8080.

## Example code

```bash
ssh -L 8080:localhost:5432 emma@203.0.113.10
```

Port 8080 on the laptop now leads to the database on port 5432 inside the server.

## Why it matters

You can keep a database off the web and still reach it yourself.

## Common mistake

Opening the database port to the world instead, just for a quick look. A tunnel gives the same access with no open door.

## Three principles

- **Inside SSH.** One login carries both.
- **Local port in.** Pick a port on your side.
- **Private stays private.** Nothing new is opened.

## Related terms

- [Secure Shell (SSH)](https://learn.benibix.com/term/infrastructure/ssh)
- [Jump Host](https://learn.benibix.com/term/infrastructure/jump-host)
- [Network Port](https://learn.benibix.com/term/infrastructure/port)
- [Localhost](https://learn.benibix.com/term/infrastructure/localhost)
- [Virtual Private Network (VPN)](https://learn.benibix.com/term/infrastructure/vpn)

## Told apart from

- [SSH Tunnel vs VPN](https://learn.benibix.com/compare/ssh-tunnel-vs-vpn): People often think an SSH tunnel is a small VPN. It is not. A tunnel carries one port to one place, inside one SSH login. A VPN joins your whole computer to a private network, so every app goes through it. Use a tunnel for one service and a VPN for a network.

## Taught in

- [SSH Tunnels and Jump Hosts](https://learn.benibix.com/learn/infrastructure-ssh/ssh-tunnels-and-jump-hosts): SSH, 8/9

![Two pictures. Top: a laptop's port 8080 is carried through an SSH tunnel to a database that only listens inside the server, on port 5432. Bottom: a laptop logs in to a jump host at the edge of a private network, and from there into a server inside that has no public address.](https://learn.benibix.com/diagrams/inf3-ssh-tunnel.svg)

---

Source: https://learn.benibix.com/term/infrastructure/ssh-tunnel
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
