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
1 Answer 1
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.
-
Thanks! I've created a separate user with a password and now I can connect to the DB.Westave– Westave2020年04月05日 08:24:13 +00:00Commented Apr 5, 2020 at 8:24
psql -W
, it will ask for a password, and then ignore it if not needed.