SSH Tunnel Generator

Generate ssh tunnel commands visually for local forwarding, remote forwarding, and SOCKS proxy — plus SSH config and systemd service files.

Ready to use Runs locally in your browser
How this tool works

Choose the SSH forwarding mode before copying a command

Use local forwarding when a service is reachable from the bastion but not from your laptop, remote forwarding when a remote host must reach a local service, and dynamic forwarding when you need a SOCKS proxy. Enter the bind address, local port, destination host, destination port, and jump host deliberately.

The generated command configures a tunnel; it does not open the SSH connection for you. Confirm that the selected ports are free, the bastion permits forwarding, and host-key verification is enabled before using it with sensitive systems.

SSH Tunnel Generator
Generate SSH tunnel commands, SSH config entries, and systemd service files for persistent tunnels.
Tunnel Type
SSH Server
Port Configuration
Quick Presets — click to load instantly
Tunnel Flow
[Local:3306] ──SSH──▶ [localhost:3306]
SSH Command

This tool runs 100% in your browser; your data never leaves your device. Privacy details

The Immediate SSH Tunnel Generator Solution

Quickly construct secure forwarding routes by entering your local port, remote host:port, and jump host details. The tool instantly outputs the correct ssh tunnel command with necessary background flags like -N and -f.

When to Reach for the SSH Tunnel Generator

Managing SSH tunnels manually often results in hanging processes or port binding errors. Generate exact tunnel commands for:

  • Accessing remote databases (like PostgreSQL) safely through bastion hosts without exposing them to the internet.
  • Forwarding local dev ports (e.g., localhost:3000) to staging servers for live client previews.
  • Creating a dynamic SOCKS proxy (-D) for secure web browsing on untrusted public Wi-Fi networks.

Common SSH Tunnel Generator Issues, Solved

Issue: bind: Address already in use
Fix: Another process (or a previous hanging tunnel) is currently bound to your requested local port. Find and terminate it using lsof -ti:PORT | xargs kill -9 before rerunning the tunnel command.

Issue: The tunnel silently drops or closes after a few minutes of inactivity
Fix: Network firewalls often kill idle TCP connections. Ensure you add the keep-alive flags to your command, and run it as a background daemon using -N -f -o ServerAliveInterval=60.

Deep Dive: Port Forwarding (-L/-R/-D), GatewayPorts & KeepAlive Daemonization

SSH port forwarding encapsulates arbitrary TCP socket streams inside an authenticated, encrypted transport layer under RFC 4254 (OpenSSH Connection Protocol). By multiplexing application data over port 22, engineers securely traverse firewalls, access isolated VPC databases, and expose staging services without configuring full-tunnel VPN software.

Operating production tunnels reliably requires understanding four core socket routing behaviors:

  • Local (-L), Remote (-R) & Dynamic (-D) Mechanics: Local forwarding (-L [local_ip:]port:target_host:target_port) binds a socket on the client to route packets through the remote SSH host to the destination. Remote forwarding (-R) binds the listening socket on the remote server to expose local development ports to external networks. Dynamic forwarding (-D port) transforms the SSH client into a local SOCKS5 proxy, routing dynamic application requests across the remote host.
  • The Loopback Binding & GatewayPorts Barrier: By default, OpenSSH binds forwarded ports strictly to 127.0.0.1. If you need colleagues or container networks to access the tunnel, you must bind to 0.0.0.0. For remote tunnels (-R), the server's /etc/ssh/sshd_config must explicitly enable GatewayPorts yes or GatewayPorts clientspecified; otherwise, the SSH daemon silently forces the socket onto the server's loopback interface.
  • Preventing Silent Disconnections with Heartbeats: Cloud NAT gateways and stateful network firewalls drop idle TCP state entries after 300–350 seconds of silence, causing the tunnel to hang without sending a TCP RST packet. Prevent orphaned tunnels by configuring ServerAliveInterval 30 and ServerAliveCountMax 3 to transmit periodic keep-alive probes over the encrypted channel.
  • Headless Daemonization Flags (-N -f -T): Running a background tunnel without opening an interactive shell requires the headless flag trio: -N (do not execute a remote command), -f (fork into background immediately after authentication), and -T (disable pseudo-terminal allocation). For mission-critical background tunnels, wrap the command in a systemd service or use autossh for automatic reconnect monitoring.

ZeroData tunnel command generation executes purely on your local device, ensuring private database ports, internal hostnames, and bastion network IP addresses remain unrecorded and private.

SSH Port Forwarding: The Developer's Swiss Army Knife

SSH port forwarding is one of the most powerful — and most underused — features of the SSH protocol. It lets you create encrypted tunnels that route network traffic between your local machine and remote servers, bypassing firewalls and NAT restrictions without installing additional VPN software.

The most common scenario is local port forwarding: you have a database server (MySQL, PostgreSQL, Redis) running on a private network with no public access. By creating an SSH tunnel, you can connect to the database as if it were running on localhost, while all traffic is encrypted through the SSH connection.

How the SSH Tunnel Generator Works

At a technical level, an SSH tunnel hijacks a TCP port on one end of the connection and securely multiplexes that traffic over the already-encrypted SSH session. Once the traffic reaches the other end of the SSH connection, it is unpackaged and forwarded to its final destination. This means any unencrypted protocol (like HTTP, VNC, or older database protocols) can be wrapped securely within SSH. The operating system handles the port binding, while the SSH client and server handle the encryption, decryption, and network routing transparently to your applications.

Three Types of SSH Tunnels Explained

Local Forwarding (-L) binds a port on your local machine and forwards connections through the SSH server to a destination host and port. Example: ssh -L 5432:db.internal:5432 user@bastion lets you access the internal PostgreSQL database at localhost:5432.

Remote Forwarding (-R) binds a port on the remote server and forwards connections back to your local machine. This is useful for exposing a locally running development server to a colleague or webhook service without deploying to a staging server.

Dynamic Forwarding (-D) turns your SSH connection into a SOCKS5 proxy. Configure your browser to use localhost:1080 as a SOCKS proxy, and all web traffic is routed through the remote server — useful for accessing geo-restricted content or internal web applications.

Advanced Use Cases for SSH Tunnels

Beyond simple database access, SSH tunnels unlock a multitude of secure networking capabilities:

  • Secure Remote Desktop: Forwarding VNC (port 5900) or RDP (port 3389) securely over the internet without exposing those vulnerable services directly to brute-force attacks.
  • Bypassing Restrictive Firewalls: Routing your web browsing through a remote server via a Dynamic SOCKS proxy when connected to restrictive public Wi-Fi networks.
  • Testing Webhooks Locally: Using remote port forwarding to temporarily expose your local development environment to receive Stripe or GitHub webhooks.
  • Connecting Multi-Tier Architecture: Securely linking application servers in one data center to database servers in another without setting up complex IPsec VPNs.
  • Accessing Internal Admin Panels: Reaching internal routers, Kubernetes dashboards, or CI/CD pipelines that are strictly isolated on management VLANs.

Making Tunnels Persistent with Systemd

A manual SSH tunnel dies when you close the terminal or when the network connection drops. For production use cases (e.g., always-on database access), you need a persistent tunnel managed by systemd. This tool generates a complete .service file with Restart=always and ServerAliveInterval keep-alive settings, ensuring the tunnel auto-reconnects after any interruption.

The SSH Tunnel Generator Works in All Modern Browsers

This SSH tunnel generator is a web-based utility that produces text commands and configuration files. It is fully compatible with all modern browsers including Google Chrome, Apple Safari, Mozilla Firefox, and Microsoft Edge. Because it does not require complex APIs like WebUSB or WebSockets, it functions perfectly across desktop and mobile devices alike, allowing you to generate and copy secure commands on the go.

Why Local Processing Matters

Network architecture and infrastructure details — like internal IP addresses, database ports, and bastion hostnames — are highly sensitive. Exposing this information to third-party services creates a major security vulnerability. 100% private — data never leaves your browser. This tool constructs the SSH commands and configuration files entirely via client-side JavaScript. We do not store, log, or transmit any of your server addresses or port numbers.

Related SSH Tools

For a complete mastery of SSH, including keys, configurations, jump hosts, and agent forwarding, read our SSH Complete Guide.

Build your complete SSH workflow with our other tools. Use the SSH Config Generator to manage host aliases, identity files, and jump hosts in your ~/.ssh/config. The SSH Command Builder helps construct complex SSH connection strings with multiple flags. And if you need to generate fresh SSH key pairs, the SSH Key Generator creates RSA keys directly in your browser using the Web Crypto API.

For running tunnels as background services, pair this tool with the Systemd Service Generator for full control over dependencies, restart policies, and environment variables.

How to Use the SSH Tunnel Generator

  1. Select the tunnel type: Local (-L) for accessing remote services, Remote (-R) for exposing local services, or Dynamic (-D) for SOCKS proxy.
  2. Enter the SSH server hostname/IP and username for the connection.
  3. Configure the local and remote ports. Use presets for common services like MySQL or PostgreSQL.
  4. Optionally specify an identity file path for SSH key authentication.
  5. Copy the generated SSH command, SSH config entry, or systemd service file.

Common Use Cases

  • Accessing a remote MySQL or PostgreSQL database securely without exposing it to the public internet.
  • Creating a SOCKS5 proxy for browsing internal network resources from outside the office.
  • Exposing a local development server to a remote testing environment using remote port forwarding.
  • Setting up persistent SSH tunnels as systemd services for always-on database access in production.
  • Forwarding VNC or RDP desktop sessions securely through an encrypted SSH tunnel.

Frequently Asked Questions

What is SSH tunneling and why do I need it?

SSH tunneling (also called SSH port forwarding) creates an encrypted channel between your local machine and a remote server, allowing you to securely access services behind firewalls, NATs, or private networks. Common use cases include accessing a remote database, creating a SOCKS proxy for secure browsing, or exposing a local dev server to a remote network.

What is the difference between Local (-L), Remote (-R), and Dynamic (-D) tunnels?

Local forwarding (-L) routes traffic from a local port through the SSH connection to a destination accessible from the remote server. Remote forwarding (-R) does the opposite — it routes traffic from a port on the remote server back to your local machine. Dynamic forwarding (-D) creates a SOCKS5 proxy that routes all traffic through the remote server, useful for browsing as if you were on the remote network.

How do I make an SSH tunnel persistent with systemd?

Create a systemd service file that runs the SSH tunnel command with the -N flag (no remote command) and configure Restart=always so it automatically reconnects if the connection drops. This tool generates the complete .service file for you. Save it to /etc/systemd/system/ssh-tunnel.service, then run 'sudo systemctl enable --now ssh-tunnel' to start it.

Why does my SSH tunnel keep disconnecting?

SSH connections can be dropped by firewalls or NAT devices that close idle TCP connections. The solution is to enable keep-alive packets using '-o ServerAliveInterval=60' which sends a heartbeat every 60 seconds. This tool includes this option in all generated configs by default.

Is it safe to configure SSH tunnels here?

Yes. This tool runs 100% in your browser. No IP addresses, hostnames, usernames, ports, or key paths are sent to any server. The command generation happens entirely in JavaScript within your browser memory.

Related Tools