Pay once. No subscription. Guide

A SQL client over SSH, without the tunnel juggling

A production database should not listen on the public internet, so the way in is through SSH: open a tunnel to the server, then point a SQL client at your end of it. Here is how that works by hand, where it goes wrong, and how BranchShell, a native SSH client with a SQL client inside, makes the tunnel part of the connection.

No account. No card. No renewal. macOS, Windows and Linux.

On a phone? Email yourself this page
A PostgreSQL table open in the BranchShell SQL client with the table tree on the left and columns and indexes on the right

Why go through SSH at all

MySQL listens on port 3306 and PostgreSQL on 5432. On a well-kept server those ports are bound to 127.0.0.1 or a private network and closed in the firewall, so nothing outside can reach them. SSH is already open, already encrypted and already tied to your keys, so it carries the database connection too. No extra port is opened and no database password crosses the internet in the clear.

The manual way: an SSH tunnel

One command forwards a port on your computer to the database on the server. Leave it running, then connect your SQL client to your own end of it.

  • MySQL or MariaDB: run ssh -N -L 3307:127.0.0.1:3306 you@server, then connect to 127.0.0.1 on port 3307.
  • PostgreSQL: run ssh -N -L 5433:127.0.0.1:5432 you@server, then connect to 127.0.0.1 on port 5433.
  • Behind a bastion: add -J you@bastion and SSH hops through it first.
  • A database on another machine in the private network: put its private address, as the server sees it, in place of 127.0.0.1.
  • The first number is the local port and is yours to choose. One above the real port avoids a clash with a database running on your own machine.

Where it goes wrong

  • The tunnel dies when the laptop sleeps or the network changes, and the SQL client reports a lost connection without saying why.
  • Two projects want the same local port, or a local database already has it.
  • A MySQL client told to connect to "localhost" uses a socket file instead of the network and never enters the tunnel. Use 127.0.0.1.
  • Every teammate keeps their own list of commands, ports and which key belongs to which server.

BranchShell: the tunnel is part of the connection

BranchShell is an SSH client first. Your hosts live in an encrypted vault on your computer with their keys, users and jump hosts. A database connection in the same vault can name one of those hosts: when you open it, BranchShell opens a forward on that host and connects through it. There is no command to keep running in another window.

  • Eight SQL engines in the table grid and the query console: MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, ClickHouse, Redshift and Turso.
  • The same keys, identities and jump host chains your terminal sessions use, so nothing is set up twice.
  • Credentials kept in the keychain, in a vault that stays on your machine, with no account and no cloud sync.
  • A terminal and SFTP on the same host, one tab away, for when the query is not enough.

What the SQL client does once you are in

  • A table grid with a WHERE bar and an ORDER BY bar, paging, and export as CSV, JSON or SQL.
  • A query console with autocomplete that runs the statement under the cursor, a selection or several, each with its own result tab.
  • Cells edited in the grid and submitted together. Modify table edits columns and indexes and shows the SQL it will run.
  • Full-text search through every column of every table.

Pay once, run it on 2 computers

BranchShell for macOS, Windows and Linux costs $20 once for 2 computers. There is no account to create and no subscription to renew, and the trial lasts 14 days with every feature.

FAQ

SQL client over SSH

Anything else? Email us at contact@branchbay.dev.

Do I have to open the database port in the firewall?
No. The database keeps listening on 127.0.0.1 or the private network. Only SSH is reachable from outside, and the database connection travels inside it.
Is a database connection through SSH encrypted?
Yes, between your computer and the SSH host. From that host to the database it travels as the database's own protocol, which is why the database usually sits on the same machine or the same private network as the host.
Which databases can BranchShell open through an SSH host?
MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, ClickHouse, Redshift and Turso with the table grid and the query console, and Redis, MongoDB, InfluxDB, DynamoDB and CloudWatch as connections.
Does it work through a bastion or jump host?
Yes. A host in the vault can hop through a chain of jump hosts, and a database connection that uses the host goes the same way.
Can I still run my own tunnels?
Yes. Local, remote and dynamic forwarding rules are saved in the vault and switched on one by one, for any other tool that needs a tunnel.

Try it on your own servers.

Every feature, free for the trial, with nothing to sign up for and nothing to renew after.