0Pricing
Cryptology Academy · Lesson

SSH Tunneling and Port Forwarding Techniques

Master local, remote, and dynamic port forwarding and understand their legitimate and security-sensitive uses.

Local Port Forwarding Concept

Local port forwarding (ssh -L local_port:destination_host:destination_port user@ssh_server) binds a port on your local machine. Traffic sent to that local port travels through the encrypted SSH connection to the SSH server, which then connects to the destination. Your local application talks to localhost while SSH securely delivers traffic to the remote destination.

Local Forwarding Use Case: Database Access

A common use case for local port forwarding is accessing an internal database behind a firewall. With ssh -L 5432:db.internal:5432 user@bastion, your local PostgreSQL client connects to localhost:5432. The bastion host forwards this traffic to the internal database server, which is otherwise unreachable from the internet.

All lessons in this course

  1. SSH Handshake and Host Key Authentication
  2. Public Key Authentication and Agent Forwarding
  3. SSH Tunneling and Port Forwarding Techniques
  4. SSH Hardening and Audit Best Practices
← Back to Cryptology Academy