Skip to content
Keepware Subscribe

Connect to a database through an SSH tunnel (bastion host)

Reach a database on a private network through an SSH bastion in QuerentDB: password or private key login, the host fingerprint check, and connections that share the tunnel.

Part 6 of 13· Nov 11, 2026·3 min read

Video · 1:22 · narrated, with captions
Transcript

A database behind a bastion. Many production databases aren't reachable from your computer. They sit on a private network, behind a bastion host you reach over SSH. QuerentDB connects through an SSH tunnel, so you don't need a VPN, and the database doesn't need a public port. Choose New connection, and pick PostgreSQL.

Fill in the connection. Name it reporting. The host is the address as the bastion sees it: reporting.acme.example, on port 5432. The database is acme_analytics, and a read-only account is all we need here. Without a read-write account, nothing can write through this connection.

Add the SSH tunnel. Under SSH tunnel, choose New tunnel. Give it a name, then the bastion's address and port, and your SSH user name. Sign in with a private key, the default, or with a password, as here. Choose Test tunnel. The first time, QuerentDB shows the bastion's host fingerprint. Check it, then choose Trust and remember.

Save the connection and its tunnel. Choose Save. The connection and its new tunnel are saved together. The tunnel shows up in the left panel, and other connections in this environment can use it too.

Browse through the tunnel. Open reporting, and its tables load through the bastion, like any other connection. From now on, Test on this connection goes through the tunnel too.

QuerentDB, a desktop database client by Keepware, can reach a database that only a bastion host can see: give the connection an SSH tunnel, and every query goes through an encrypted SSH connection to the bastion and on to the database. You don’t need a VPN, and the database doesn’t need a public port. A tunnel signs in with a password or a private key (OpenSSH, PEM or PuTTY .ppk), checks the bastion’s host fingerprint the first time, and can be shared by every connection in the same environment.

How do I connect through a bastion host?

  1. Choose New connection in an environment and pick the Type.
  2. Enter a Name, and as Host the database’s address as the bastion sees it: a private hostname such as reporting.acme.example, or a private IP address, with its port.
  3. Fill in the database and the accounts. A read-only account is enough to browse and query; add a read-write account only if you’ll write.
  4. Under SSH tunnel, choose + New tunnel…, then open the SSH tunnel tab.
  5. Enter a Name for the tunnel, the bastion’s address and port under Server, your SSH User name, and under Authentication either Private key (paste it or Choose file…, plus its Passphrase if it has one) or Password.
  6. Choose Test tunnel. The first time, QuerentDB shows the bastion’s Host fingerprint; check it with whoever runs the server (on the server, ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub prints it) and choose Trust and remember.
  7. Choose Save. The connection and its new tunnel are saved together.

The SSH tunnel tab: server, user, password, and the bastion's host fingerprint to trust

Open the connection: its tables load through the bastion, and the status bar shows Via and the tunnel’s name. From now on, Test on the connection goes through the tunnel too.

The reporting database opened through the tunnel; the status bar says Via bastion

Can several connections share one tunnel?

Yes. A tunnel belongs to its environment and appears in the left panel under it, marked SSH. Any connection in that environment can pick it under SSH tunnel, and the tunnel’s sheet lists which connections use it. Edit a tunnel to change its server or login, and every connection that uses it follows.

What happens if the bastion’s fingerprint changes?

QuerentDB refuses to connect and shows Host fingerprint changed. Connection refused, with the fingerprint it trusted before and the one it received now. If the server was really reinstalled or its key rotated, confirm the new fingerprint with whoever runs it and choose Verified: trust the new fingerprint. Otherwise, someone may be intercepting the connection: don’t trust it.

Does the database connection still need TLS?

Traffic between your computer and the bastion is encrypted by SSH, so a plain-text database protocol inside the tunnel isn’t exposed on the way. Between the bastion and the database it’s the database’s own connection: keep TLS on (Prefer or Require) if that network isn’t trusted. An environment with Require TLS refuses connections without TLS, tunnel or not.

Does it work with MongoDB replica sets and Atlas?

Yes. With a tunnel, every replica-set member is reached through the bastion (as a SOCKS proxy), so discovery and primary failover keep working. For mongodb+srv:// addresses, the SRV and TXT records are resolved on your computer, and the members are then reached through the tunnel; private Atlas endpoints that your computer can’t reach work this way.

Where are SSH passwords and private keys kept?

On your computer, encrypted, with the key in the system’s credential store; a private key is only read when the tunnel connects, and never shown again after you save it (paste or choose a new one to replace it). In a team workspace, tunnels are shared end-to-end encrypted like connections, and only members with access to the environment receive them.

FAQ

Is SSH agent forwarding or an SSH agent supported?

Not yet. Use a private key file or a password.

Can I use a jump host chain (ProxyJump)?

Not yet: a tunnel goes through one bastion.

My key uses a passphrase. Is that supported?

Yes. Enter it under Passphrase; it’s kept encrypted with the key.