'Use openssh proxyjump to connect to database

I have the following network configuration

localhost -> proxy -> databaseserver

I'm using OpenSSH ProxyJump to establish a cli ssh connection from my localhost to the databaseserver without having to deal with an explicit tunnel. It works fine ! Here's a sample configuration of my ssh/config file

[me@localhost] cat .ssh/config
Host databaseserver
User user
HostName databaseserver_ip
ProxyJump user@proxy
[me@localhost] $ ssh user@databaseserver
[user@databaseserver] $

There's no hint about databaseserver's ip in my localhost's /etc/hosts file

What I am trying to achieve is to use ProxyJump with psql (or any other graphical software) in order to avoid creating a dedicated ssh tunnel. ie :

[me@localhost] $ psql -H user@databaseserver

But that does not work at all ! databaserver is unknown to the psql software. It does not seem to consider .ssh/config content.

Is there a way to run a proxyjump connection with something else than the ssh command ?



Solution 1:[1]

I have run into the same problem and I'm afraid the answer is no, it is not possible to force psql to use the SSH configuration.

Alternatives

Server-side PSQL

If you are happy to run psql on a remote server instead of (or in addition to) your local machine, you might want to use the following syntax:

ssh -t your-proxy \
  psql -h database-server \
    -U user db-name

Because you are invoking SSH locally, it does take your local SSH config into consideration but the fact psql is actually running on the server may or may not be what you want. E.g. if you wanted to read or write some SQL files, they would be interacted with on that remote box, not your local machine.

GUIs

A little off-topic but I have also tried a few GUI applications: Postico, PgAdmin and DataGrip and I've only had success with the latter. It actually explicitly mentions reading the config file in the SSH Configuration modal:

enter image description here

It's worth mentioning the other two GUI apps I've tried require an SSH tunnel to achieve the same outcome. And also, please note, DataGrip requires a commercial licence to run.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris Kobrzak