Lion Cipher Lab

SSH tunneling and port forwarding: reach a service that isn't directly reachable

Why it matters

Sooner or later a service you need isn't directly reachable — a database that only listens on localhost, an admin panel bound to an internal network, a dashboard on a machine buried behind a jump host. The lazy fix is to expose it to the world and hope. The right fix is often already in your hands: SSH can carry another connection inside the encrypted session you already trust. That is a tunnel, and port forwarding is how you steer it. Learn the three shapes — pull a remote service down to a local port (-L), push a local service out to a remote port (-R), or turn one SSH session into a…

What you'll learn

Steps in this lab

  1. What a tunnel is, in one breath
  2. Set up a local SSH endpoint you control
  3. Stand up a throwaway service to reach
  4. Local forwarding (-L): pull a remote service down to a local port
  5. Remote forwarding (-R): push a local service out to the remote side
  6. Why the reverse tunnel is also an attacker's favorite — watch for it
  7. Dynamic forwarding (-D): one SSH session as a SOCKS proxy
  8. Handy flags and putting forwards in ssh_config
  9. When a tunnel is the right tool — and when it isn't

Open the full interactive lab →