Technical

SSH Tunnel

SSH tunnel: an encrypted link that brings a service running on a remote machine onto your own computer, without ever exposing that service to the Internet.

Tube de verre horizontal reliant deux blocs de métal sombre, parcouru par un fin faisceau de lumière blanche, avec un halo bordeaux à son extrémité droite, au-dessus d’un sol sombre réfléchissant
Tunnel SSH — Image générée par IA (Qwen-Image 2.1, ComfyUI)

An SSH tunnel is an encrypted link that makes a service running on a remote machine appear on your own computer. The service stays invisible from the Internet: you reach it through the SSH connection, the same one used to administer the server. It's the simplest way to use a sensitive tool without exposing it.

Technical definition

Forwarding a port

SSH, the protocol used to administer servers remotely, can carry more than commands. With port forwarding, it listens on a port of the local computer and sends everything it receives there to a port on the remote machine. A local application thinks it's talking to a local service; its traffic actually travels through the encrypted connection.

Three possible directions

Local forwarding brings a remote service to your computer: it's the most common case. Remote forwarding does the opposite, making a service on your computer reachable from the server. Dynamic forwarding turns the connection into a generic relay through which you can route several destinations.

Nothing to install on the service side

The forwarded service doesn't need to handle encryption or authentication: SSH takes care of both. That's what makes the tunnel so valuable for tools with no protection of their own, like many AI model servers and development interfaces.

Current challenges

AI services without authentication

Tools that serve a language model locally often listen without a password, because they're designed to be used on your own machine. Installed on a rented server, they must never listen on the Internet. An SSH tunnel lets you use them remotely while keeping them closed.

A security blind spot

What makes the tunnel powerful also makes it risky. Someone with SSH access can reach internal services the firewall is supposed to isolate, and the encrypted traffic escapes inspection. Security teams therefore restrict which forwards are allowed on sensitive servers.

An individual solution

A tunnel suits one person and an occasional need. As soon as several users depend on the same access, an administered solution is better: a bastion host, a VPN or zero-trust network access.

Standards and Specifications

RFC 4254 — SSH Connection Protocol

IETF standard published in January 2006, whose section 7 defines the TCP/IP port forwarding used by SSH tunnels

Frequently Asked Questions

What is an SSH tunnel used for?

To use a service running on another machine from your own computer, as if it were local. A database, an admin interface or an AI model stays closed to the Internet on the server. Only the person holding the SSH key can open the tunnel and reach them, through an encrypted connection.

What is the difference between an SSH tunnel and a VPN?

A VPN connects an entire computer to an entire network. An SSH tunnel connects one specific port to one specific service. The tunnel is narrower, so it's simpler to set up and to reason about: all it needs is SSH access, with no extra software. A VPN is still the better choice when several people need lasting access to many services.

Is an SSH tunnel secure?

It's as secure as the SSH access behind it. With key-based authentication instead of a password, and a well-protected private key, it's a proven method. Two things to watch: the forwarded service becomes reachable by any program running on the computer, and a tunnel opened by a colleague can bypass firewall rules without anyone noticing.

Resources and Documentation