SSH Tunneling Guide

Published
Length
3 min read

Luis Felipe Dias

All posts

You create an encrypted tunnel by forwarding a local port through an SSH server. This ssh tunneling guide explains how to route network traffic to private internal hosts. Teams often set up a shared bastion or jump host to reach private networks. When permissions on that host are too broad, one person can reach every internal port. An ssh tunneling guide to local and remote port forwarding SSH tunneling wraps standard network traffic inside an encrypted SSH connection. A user starts a session

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You create an encrypted tunnel by forwarding a local port through an SSH server. This ssh tunneling guide explains how to route network traffic to private internal hosts. Teams often set up a shared bastion or jump host to reach private networks. When permissions on that host are too broad, one person can reach every internal port.

An ssh tunneling guide to local and remote port forwarding

SSH tunneling wraps standard network traffic inside an encrypted SSH connection. A user starts a session from their laptop to a bastion host. The SSH client listens on a local port on the engineer's machine. When an app sends traffic to that local port, the SSH client grabs it. The client encrypts the packets and sends them through the SSH pipe.

The bastion receives the data, decrypts it, and forwards it to the final destination. That destination might be a private database or an internal web service. The internal server sees the traffic coming from the bastion host itself. Reverse or remote port forwarding works in the opposite direction. It opens a port on the remote server and routes traffic back home. Teams also use OpenSSH certificates to manage who can log into the jump host. A certification authority key signs a user public key and adds principal names. The signed certificate also holds options that control what the SSH session can do.

How SSH certificates control logins and where network rules stop

Native OpenSSH features solve the problem of static public keys scattered across servers. Instead of copying keys to every host, admins trust one certification authority key. The signed certificate includes identity data and a list of allowed user principals. Admins can also set a time window so the certificate expires on schedule. Without an expiration window set during signing, a certificate stays valid forever.

Certificate options can restrict port forwarding or limit which commands a user runs. Still, once a tunnel is open, SSH only moves raw TCP bytes. The SSH server checks who can log in and open the port. It does not inspect the database queries or HTTP calls inside the tunnel. An engineer with an open tunnel to a database port has full network reach. The bastion log shows that a connection happened, not which queries ran. It cannot block a destructive query or rewrite sensitive fields like emails or phone numbers.

SSH Tunneling Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why broad bastion access creates blind spots for security teams

In many setups, dozens of engineers share the same OS user on a bastion. Even with individual accounts, firewall rules often let the jump host reach whole subnets. If an engineer can forward ports through that host, they inherit its network reach. They can point their local client at any database or internal admin panel.

Standard SSH logs record the login event and the open channel. They do not parse the protocol running inside the forwarded port. If someone runs a bulk export over a tunnel, the host log stays quiet. Security teams see an active SSH session, but they miss the actual data queries. Auditing requires knowing every command and query, not just the network handshake.

Inspect one-shot SSH commands and file tasks

SSH certificates and host rules decide who is allowed on a machine. Setup alone does not check single commands or block sftp reads on sensitive paths. By design, hoop.dev runs an open-source SSH listener on the host where people and agents keep their normal ssh, sftp, and scp tools.

First, hoop.dev guardrails check one-shot commands and file paths before they run. Next, hoop.dev data masking masks matched values in file downloads. The audit trail logs the certificate principal, requested action, and verdict without storing session content. Interactive shells carry no guardrails and can be turned off when every action must be checked. Explore the code on GitHub.

Frequently asked questions

What is the difference between local and remote SSH port forwarding?

Local forwarding sends traffic from your laptop through the SSH server to a private target. Remote forwarding opens a port on the SSH server and sends traffic back to you.

How do OpenSSH certificates improve bastion login security?

A central authority signs user keys with an identity, allowed principals, and a set lifespan. Servers trust the authority key instead of storing static public keys for each user.

Can an SSH server see the database queries inside a port forward?

No, the SSH daemon only forwards raw TCP packets between the client and the target. It does not read, log, or filter the SQL statements or data inside the tunnel.

The query runs. The emails stay hidden.