Est.

Connecting Database GUI Tools Securely via SSH Tunnels

A step-by-step guide to SSH tunnels that keep databases private.

· 8 min read
Cover illustration for “Connecting Database GUI Tools Securely via SSH Tunnels”
Database GUIs and Clients · November 10, 2026 · 8 min read · 1,912 words

For a growing startup, secure database self-service needs two layers, an SSH tunnel for private connectivity and a permissioned interface that non-engineers can use without handling credentials. Engineering or data teams should look after the connection and permissions. Local port forwarding makes the tunnel work, but it does not make a SQL editor a no-SQL interface. Choosing a database GUI therefore means judging both its connection security and who can actually use it.

Why databases should not be directly reachable from the internet

MySQL listens on port 3306 by default, while PostgreSQL uses 5432. If either port is open to the public internet, it stays a target for brute-force and unauthorized-access attempts. A database password is not a reason to expose that target. The safer arrangement keeps the database bound to 127.0.0.1, where only connections originating on the server can reach it.

How, then, does a GUI on a laptop get in? The route is an encrypted SSH connection, where SSH credentials let the client reach the server and separate database credentials open the database session. Stealing one does not automatically provide the other. Because the database remains bound to loopback, a misconfigured tunnel does not itself make the database publicly reachable. The SSH tunnel is the standard answer to this problem, and understanding its forwarding mechanism makes the setup much less mysterious.

What local port forwarding actually does, step by step

Local port forwarding gives the GUI a nearby address for a distant database. The SSH client opens a listening port on the local machine, such as 3307, and forwards connections arriving there through the encrypted SSH session. At the other end, the server connects to its own loopback address on port 3306. Picture the route as a simple chain. The local GUI reaches local port 3307, crosses the encrypted SSH connection, and arrives at the server’s loopback interface before reaching MySQL.

The two port numbers serve different jobs. Port 3307 is the local entrance, while 3306 is the database’s destination port on the server. Using 3307 also avoids a conflict if MySQL is already running locally on its default port. From the remote database’s perspective, the incoming connection is local, so the MySQL account needs the appropriate localhost host setting. The GUI is remote, but its connection arrives wearing local shoes.

In this arrangement, SSH encrypts the laptop-to-server segment. The final connection stays on the server’s loopback interface. That distinction will become important when a bastion host and database live on separate machines. For now, the database and SSH endpoint share a server.

The terminal version uses SSH’s -L option for local forwarding. The -N option keeps the connection open without running a remote command, while -f puts the process in the background after authentication. To stop a backgrounded tunnel, find its PID with ps aux | grep "ssh -f -N -L 3307" and kill that process. Its lifetime still depends on the SSH session. Idling or a network interruption can close it, and ServerAliveInterval 60 with ServerAliveCountMax 3 in the SSH configuration helps prevent a silently dead connection.

Server-side prerequisites before the tunnel can work

Before configuring a GUI, check the server itself. Most confusing connection failures begin at this layer, where an otherwise correct tunnel can lead to a database that is not listening as expected or will not accept the account. For MySQL, check that bind-address is set to 127.0.0.1 in /etc/mysql/mysql.conf.d/mysqld.cnf. If it is set to 0.0.0.0 or a public IP, change it and restart MySQL.

Next, check the MySQL account’s host setting. Use localhost instead of a public IP or % for the tunnel connection. This setting concerns where the database sees the connection originate. Separately, confirm SSH is running with sudo systemctl status sshd, and start and enable it if necessary.

The firewall should allow SSH on port 22. It should not need to allow MySQL on 3306 or PostgreSQL on 5432, because avoiding that exposure is the point of the exercise. For PostgreSQL, the database also needs to be available locally and reached through SSH. Opening the database port to fix a failed tunnel defeats the design. It replaces a connection problem with an exposure problem.

A dedicated tunnel user is worth setting up now. The hardened pattern uses ForceCommand /bin/false to prevent an interactive shell, restricts AllowTcpForwarding to local forwarding, and uses PermitOpen in sshd_config to limit the destination. Those controls constrain what the SSH account can reach rather than merely deciding whether it can log in. Database permissions provide another boundary. A read-only GUI account with grants limited to reading data limits the damage an accident or misconfiguration can cause.

Setting up the tunnel on Windows using PuTTY

Windows users without OpenSSH in their path can configure the same forwarding arrangement in PuTTY. Its graphical port-forwarding settings replace the terminal’s -L option. Configure the SSH server connection, then set up local forwarding with source port 3307 and a destination of localhost on port 3306. Here, destination localhost means the remote server’s loopback address. It does not mean the Windows machine.

After opening and authenticating the SSH session, keep it running while the GUI uses the tunnel. Save the PuTTY session by name so later connections become a one-click operation. Readers who prefer ssh -L can also get OpenSSH through optional features in Windows 10 and 11. Either route produces the same local entrance. Once the tunnel is running, a GUI that uses that external tunnel connects to localhost on port 3307 on any operating system.

Which GUI database tools fit a team that needs self-serve data?

Most major database GUIs can manage SSH forwarding internally, making a separate PuTTY or terminal session optional. In a built-in setup, the connection settings describe both the SSH route and the database destination. This distinction prevents a common mix-up. Local port 3307 is for the example where the tunnel is managed separately, while a built-in tunnel needs the destination settings for the remote database.

For a startup choosing a tool, the useful criteria include database support, tunnel management, query-writing needs, and permission administration. A polished editor is not automatically a no-SQL interface. Operations and marketing teams need a permissioned interface they can use without filing tickets or touching credentials, while engineering or data teams handle access behind it. The tools below address the connectivity and database-work side of that arrangement. Their SSH support alone does not establish that they meet the non-technical interface requirement.

DBeaver Community Edition is a free option for Windows, macOS, and Linux, with support for 100+ databases. Its built-in SSH handling starts the tunnel and presents the remote database as locally accessible. Database connections with matching SSH configurations can share a running tunnel without starting extra tunnel processes. Several databases on the same server can share a tunnel this way. Its SSH configuration panel also supports jump hosts, and there is a paid Pro edition.

MySQL Workbench is Oracle’s free, MySQL-focused choice. Set the connection method to “Standard TCP/IP over SSH” to use its built-in tunnel. Enter the SSH hostname, username, and key or password, followed by the MySQL hostname, port, and database credentials. For the same-server example, the MySQL hostname is localhost and the port is 3306. Both authentication layers appear in the same dialog, but they remain separate checks.

pgAdmin 4 is free, open-source, and specific to PostgreSQL. It supports encrypted connections that protect credentials and data in transit, and it can also run as a web app in Docker for browser access. Browser access changes where the interface runs. It does not, by itself, establish that non-engineers can query data without SQL. For teams comparing it with Workbench, the database engine is the first clear dividing line.

DataGrip is JetBrains’ paid, cross-platform option, with a built-in tunnel configured through its SSH/SSL tab. With its intelligent code completion, query debugging, performance profiling, and version control integration, it is closer to an integrated development environment for database work. Beekeeper Studio Community Edition instead offers a free, open-source option on Windows, macOS, and Linux, with SSH support in the connection dialog. Its interface is built on a desktop application framework and has dark mode and a tabbed query editor, and there is also a paid Ultimate edition.

TunnelForge is an open-source option for Windows and macOS beta, updated July 2026, built around reaching MySQL and PostgreSQL through a bastion host. It has SSH tunnels, a SQL editor, backup and restore, and migration between those database engines. Its Tunnel Groups have color-coded groups, drag-and-drop reordering, and controls for handling connections in bulk. Connection upkeep gets explicit attention, too. Real-time health checks, auto-reconnect, and a detail view of connection duration and recent events make tunnel management part of the interface.

The staging-vs-production confusion risk and how to prevent it

When staging and production share a bastion, a mistaken LocalForward can send a client to production while the person using it believes they are on staging. Encryption does not detect that misunderstanding. Use separate bastion hosts where possible, or at least separate SSH configuration entries with unmistakable names such as pg-prod and pg-stage. Color-coded GUI connections, including TunnelForge’s groups or TablePlus’s color labels, add a visible distinction.

Server-side restrictions can make that distinction enforceable. PermitOpen limits a tunnel user to one destination, so a mistaken client configuration cannot simply redirect it to another database endpoint. TunnelForge’s Production Guard adds a separate safeguard by opening production profiles read-only and requiring the schema name to unlock writes. Keep tunnel entries in version control or a shared SSH configuration template so developers use settings that have been reviewed instead of making ad-hoc configurations that drift apart.

Where SSH tunnels reach their limits and what to use instead

SSH tunnels fit local development, ad-hoc debugging, and controlled GUI access. They are not a scalable substitute for a VPN or identity-aware access proxy once access spreads beyond a handful of engineers. Provisioning keys on a bastion is manageable for a small group, but at twenty or more developers it becomes an access-management problem without additional tooling. A growing startup can have a much smaller group administering database connections.

The topology also changes the encryption claim. When SSH and the database share a server, the final segment stays on loopback. With a separate bastion, SSH encrypts the laptop-to-bastion segment, while the bastion-to-database segment crosses the private network in cleartext unless separately protected. For PCI or HIPAA workloads, TLS on the database connection remains required even inside the VPC. A private network is not an encryption spell.

Nor is a shell restriction a complete zero-trust design. A stolen tunnel-user key can sometimes allow lateral movement even with ForceCommand /bin/false, especially on a flat private network. For persistent infrastructure access across a whole team, VPNs such as WireGuard and OpenVPN offer split routing, DNS leak protection, and centralized management that SSH tunnels lack. The trade-off is operational overhead and added latency. VPNs add more milliseconds than a tunnel after the handshake.

Teleport from Gravitational takes the identity-aware route. It replaces static keys with short-lived certificates, uses reverse tunnels to eliminate inbound firewall rules, and provides identity-based access across SSH, Kubernetes, databases, and apps, with audit logs and session playback. Its extra network and TLS hop warrants benchmarking for high-throughput or latency-sensitive workloads. For a startup where a small group still manages access, a restricted SSH tunnel beneath a permissioned interface is a practical choice that takes little work to run and avoids giving every non-engineer an SSH key or a SQL editor.

More in Database GUIs and Clients