Sample Header Ad - 728x90

Is it possible to use PgAdmin 4 over SSH tunnel and 'sudo su - postgres'?

0 votes
1 answer
133 views
I want to use GUI, e.g., PgAdmin 4, on a PotsgreSQL on Red Hat Enterprise Linux 9, and my Linux username has SUDO permissions. With command line, I will login through SSH, and call sudo su - postgres, then call psql as the PostgreSQL superuser to connect through the UNIX socket at /run/postgresql/.s.PGSQL.5432. However, if using PgAdmin 4, its connection has a tab of "SSH Tunnel", but I am not sure whether I can add sudo su - postgres and connect through the UNIX socket. Another workaround is to add a password to the superuser postgres, then connect through SSH tunnel to the port 5432 on the localhost. But, the additional step of setting password is not very elegant. We have seen a similar question [PgAdmin 4 - How to connect to database using unix socket via ssh tunnel?](https://dba.stackexchange.com/questions/279060/pgadmin-4-how-to-connect-to-database-using-unix-socket-via-ssh-tunnel) . However, I want to access the UNIX socket as postgres while this user does not have SSH. So, I have a SUDO Linux login and hope to access the UNIX socket as postgres, like doing sudo su - postgres in CLI. For this specific part, I could not find the answer in the referred article above. Thank you for your understanding. We highly appreciate any hints and suggestions.
Asked by Mike (57 rep)
Jan 15, 2025, 09:56 PM
Last activity: May 4, 2025, 02:27 PM