logo of Akmatori
18.09.2025

A Complete Guide to SSH Tunnels: Local, Remote, and Dynamic

head-image

SSH is more than secure shell access. It also allows tunneling. With SSH tunnels, you can forward traffic securely across networks.

This guide explains local, remote, and dynamic SSH tunnels. We’ll cover their use cases and examples.

What is an SSH Tunnel?

An SSH tunnel routes traffic through an encrypted channel. It acts like a secure bridge between your machine and a remote host.

You can forward ports, secure applications, or bypass restrictions. SSH tunnels are useful in DevOps, SRE, and everyday networking.

Why Use SSH Tunnels?

SSH tunnels are powerful because they:

  • Encrypt sensitive data
  • Bypass firewalls and restrictions
  • Expose services safely
  • Test applications in different environments

For engineers, they simplify secure access to remote services.

Local Port Forwarding

Local forwarding sends traffic from your local machine to a remote host.

Syntax

ssh -L [LOCAL_PORT]:[DESTINATION_HOST]:[DESTINATION_PORT] user@ssh-server

Example

Forward local port 8080 to a remote DB on port 3306:

ssh -L 8080:db.example.com:3306 [email protected]

Now, connecting to localhost:8080 reaches the database securely.

Remote Port Forwarding

Remote forwarding does the opposite. It lets a remote host access a local service.

Syntax

ssh -R [REMOTE_PORT]:[DESTINATION_HOST]:[DESTINATION_PORT] user@ssh-server

Example

Expose your local web server (port 3000) to a remote host:

ssh -R 8080:localhost:3000 [email protected]

Now the remote host can access your app at localhost:8080.

Dynamic Port Forwarding

Dynamic forwarding turns SSH into a SOCKS proxy. It’s useful for routing browser or app traffic.

Syntax

ssh -D [LOCAL_PORT] user@ssh-server

Example

ssh -D 1080 [email protected]

Then, set your browser’s proxy to localhost:1080. All traffic goes through the SSH server.


Common Use Cases

SSH tunnels are used for:

  • Secure database access
  • Testing services behind firewalls
  • Remote debugging
  • Protecting traffic on untrusted networks
  • Bypassing geo-blocks with SOCKS proxy

They’re versatile for both admins and developers.


Security Considerations

Tunnels are powerful, but also risky if misused. Follow these tips:

  • Restrict tunnel usage with AllowTcpForwarding in sshd_config
  • Use firewall rules to limit access
  • Prefer keys over passwords
  • Monitor active tunnels

A secure tunnel should not become an open door.


Going Beyond SSH Tunnels

SSH tunnels solve many problems. But managing multiple tunnels, alerts, and incidents can still cause stress.

That’s where Akmatori comes in. Akmatori is an AIOps platform that automates incident response. It reduces downtime, handles alerts, and prevents on-call fatigue.

Try Akmatori today and simplify your workflow.


Need Reliable Servers for SSH Tunnels?

SSH tunnels require stable and fast servers. If you need global infrastructure, try Gcore.

Gcore provides cheap virtual machines and bare metal servers worldwide. Ideal for running secure bastion hosts or proxies.

Check out Gcore for your next deployment.


Conclusion

SSH tunnels are more than just port forwarding. They provide secure access, flexibility, and control over traffic.

With local, remote, and dynamic tunnels, you can:

  • Securely connect to databases
  • Share services safely
  • Route traffic through trusted servers

Used wisely, they’re an essential tool for any engineer.

Maximize your website or application's performance and reliability!