2

When opening the psql console, there is no password prompt. This behaviour is the same for all postgres users. I can basically do everything without a password. This seems rather unsafe.

How do I enable password checking? I'm running macOS Mojave and use Postgres.app with postgresql version 10.

This is the command I use:

psql -Umyuser # this user has a password set
2
  • 1
    In lieu of posting a self-answered question, it would be tidier (and polite) to upvote the Q&A where you found the solution or to post a new answer there if you feel you have something productive to add 😊 May 16, 2019 at 9:40
  • I was in doubt about this one. It is subtly different, since sudo is involved, so it could be argued to be a different question. But in any case it was not my intention to be impolite, will definitely keep your remarks in mind!
    – Thijs
    May 20, 2019 at 9:45

1 Answer 1

1

Found the answer in another post on stackexchange.

I've edited the authentication lines in pg_hba.conf and changed "trust" into "password" for all lines. It now looks like this:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

local   all             all                                     password
host    all             all             127.0.0.1/32            password
host    all             all             ::1/128                 password
local   replication     all                                     password
host    replication     all             127.0.0.1/32            password
host    replication     all             ::1/128                 password

Now psql asks me for a password every time.

1
  • From PostgreSQL docs: "password - Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks." Sep 5, 2021 at 19:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.