5

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.

Anusha
  • 204
  • 1
  • 4
  • 12
  • [duplicate post](https://stackoverflow.com/questions/45195422/mysql-connection-in-gui-via-two-ssh-connections-on-mint) has the solution for multiple remote host connection in DBeaver – Zaliqa Rosli Oct 10 '19 at 19:07

1 Answers1

16

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.

furman87
  • 928
  • 13
  • 20
  • I get this error: "FATAL: Ident authentication failed for user "user_name". Do I need to edit postgresql.conf? – rjose Jan 11 '22 at 10:17
  • I would make sure that you can connect with psql on the remote box first. You may have to edit your pg_hba.config file based on [this post](https://stackoverflow.com/questions/50085286/postgresql-fatal-ident-authentication-failed-for-user). – furman87 Jan 11 '22 at 16:06
  • 1
    The error was here : I had to replace localhost to 127.0.0.1. Not sure why, it might be the entry in config file. I am new to Ubuntu and couldn't find the config file – rjose Jan 14 '22 at 11:17
  • 1
    I edited the answer to include 127.0.0.1 as an alternative. Thanks for the info. – furman87 Jan 18 '22 at 03:14
  • 1
    I am trying to connect to another server and it doesn't ask for password when I connect from Terminal. DBeaver insists on giving a password. Is there a way to handle this situation? – rjose Jan 18 '22 at 07:12