Linux for Developers
/Advanced
SSH Tunneling (Port Forwarding)
Definition
A method of transporting arbitrary networking data over an encrypted SSH connection. It can be used to bypass firewalls or securely access local services running on remote machines.
Explain Like I'm New
Creating a secret, encrypted underground tunnel from your laptop directly into a locked server, allowing you to access a private database as if it were running on your own computer.
Real World Example
A production database on a server only listens to `localhost:5432` for security. You cannot connect DBeaver from your laptop. You create an SSH tunnel (`ssh -L 5432:localhost:5432 admin@server`). Now, your laptop's local port 5432 is secretly wired to the server's database, and you connect securely.
Common Use Cases
- •Securely accessing private databases
- •Bypassing corporate firewalls
Interview Questions
basic
- Is the data sent through an SSH Tunnel encrypted?
intermediate
- What is the difference between Local Port Forwarding (`-L`) and Dynamic Port Forwarding (`-D`)?