6

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

asked Apr 4, 2020 at 11:08
3
  • What error are you getting? Usually a postgres password is ignored if not needed. Are you complaining about the database password, or the "identify file" password? Commented Apr 4, 2020 at 12:52
  • About the database password. When I work with psql through a console, it doesn't require me to enter postgres password. Commented Apr 4, 2020 at 13:11
  • psql (by default) tries to connect without a password, and if rejected for want of a password it then asks for a password and tries again. That would be awkward to do in a GUI. If you use psql -W, it will ask for a password, and then ignore it if not needed. Commented Apr 4, 2020 at 13:52

1 Answer 1

2

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.

answered Apr 4, 2020 at 15:32
1
  • Thanks! I've created a separate user with a password and now I can connect to the DB. Commented Apr 5, 2020 at 8:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.