Connecting dbeaver to postgres hosted on remote server

We are using postgres db hosted two servers away, (pardon my jargon) we usually connect through terminal like:

local =>(using google auth) ssh server 1 =>(using google auth) ssh server 2 => psql -h Hostname -U Uname -d DBName

But, this is a hectic process and I'd like to connect to the DB through Dbeaver.

I browsed online and I figured it could be done with SSH tunneling but I could only hop through one server and it does not connect to the other.

Appreciate your help, thanks in advance!

My trials:

ssh -A -t host1.host.server1.com \ -L 5432:localhost:5432 \ ssh -A -t queries.host.server2.com \ -L 5432:localhost:5432

and I couldn't successfully connect. Even if I did connect, T'd only be connected to the machine but to access the DB I'll have to run the psql command. I'm totally lost after this point.


Solution 1:

This worked for me, but only connecting to a single remote host. Edit your connection, and in the Connection Settings->Main tab, put the following:

Host: localhost (or 127.0.0.1 if localhost doesn't work)
Database: your_database_name
User: your_database_user_name
Password: your_database_password

Then on the Connection Settings->SSH tab, enter the following:

Check "Use SSH Tunnel"
Host/IP: your_remote_host_name or your_remote_ip
Port: 22
User Name: your_remote_user (not database user)
Authentication Method: Public Key
Private Key: path_to_your_private_key (.pem or .ppk file)
Passphrase: your_private_key_passphrase (leave blank if you didn't use one)

Then test connection.