Postgresql – PgAdmin 4 – How to connect to database via ssh tunnel as posgres when its password is empty

postgresql

I am trying to connect to a Postgres database at my DigitalOcean instance via PgAdmin 4.

I create an SSH tunnel as root, provide the PgAdmin with my identify file. I want to login into database as postgres user which doesn't have a password.

So PgAdmin doesn't let me log in and requires the password for the postgres user.

Does user postgres have to have a password if I want to connect via SSH tunnel? Is it possible? And what should I do in order to connect?

step1-general
[step2-connection
step3-ssh-tunnel

Best Answer

Does user postgres have to have a password if I want to connect via SSH tunnel? Is it possible? And what should I do in order to connect?

Generally it does.

Your SSH tunnel is configured so that the remote SSH server connects to PostgreSQL through a TCP connection to localhost. And generally, a default pg_hba.conf maps this type of connection to the md5 authentication scheme, for which a password is required. Otherwise any user with a shell account could connect to PostgreSQL, which would be wrong as a default configuration.

The more common way to use PostgreSQL through a SSH tunnel is to set a password to the PostgreSQL databases accounts that you need to connect to. Use the \password command inside psql or the ALTER USER SQL statement.