Course contentsShow
← Security
Lesson 499 of 3,05211. Network Security - VPNs and TunnelingFree lesson

SSH Tunneling Fundamentals

Understanding SSH port forwarding basics, local vs remote vs dynamic forwarding, and common use cases for tunneling.

SSH Tunneling Fundamentals

What you'll learn: How SSH can create encrypted tunnels to securely forward network traffic between systems.

What Is SSH Tunneling?

SSH tunneling (also called SSH port forwarding) uses the SSH protocol to create an encrypted "tunnel" through which you can route other network traffic. Think of it like sending a package through a secure courier service—the SSH connection wraps your data in encryption, safely carrying it from point A to point B even across untrusted networks.

Three Types of SSH Forwarding

Local Port Forwarding (-L) redirects traffic from a port on your local machine through the SSH server to a destination. You're pulling remote resources to yourself. Example use case: accessing a database server that only accepts connections from within its internal network.

Remote Port Forwarding (-R) redirects traffic from a port on the remote SSH server back to your local machine or another destination. You're pushing local resources outward. Example use case: allowing a remote colleague to access a service running on your laptop.

Dynamic Port Forwarding (-D) creates a SOCKS proxy on your local machine that routes all applications through the SSH tunnel. Example use case: browsing the web securely through an encrypted tunnel, similar to VPN functionality.

Common Use Cases

  • Bypassing firewalls: Accessing blocked services through an allowed SSH connection
  • Securing unencrypted protocols: Wrapping plain HTTP or database traffic in SSH encryption
  • Remote administration: Accessing internal management interfaces from outside networks
  • Privacy: Routing traffic through a trusted server to hide your origin IP

Key Takeaway: SSH tunneling leverages the SSH protocol to create encrypted pathways for forwarding network traffic, with local, remote, and dynamic modes serving different routing needs—from accessing remote services to creating ad-hoc proxy connections.