0

I have already changed all the 'trust' values in pg_hba.conf to 'md5', restarted and reloaded postgres, but even though I've specified that my user requires a password, postgres does not require a password when I log in using: psql -U test -d financestracker. What else could I be missing?

Leaozinho
  • 139
  • 1
  • 13
  • Is it already set up in the password file? https://www.postgresql.org/docs/13/libpq-pgpass.html – Hambone Mar 15 '21 at 21:36
  • `PGPASSWORD` env variable, `.pgpass` file, more than one instance of PG running, which means more than one pg_hba.conf file – clamp Mar 15 '21 at 21:37
  • thank you @clamp - how can I check these things? – Leaozinho Mar 15 '21 at 22:07
  • https://stackoverflow.com/questions/3602450/where-are-my-postgres-conf-files (`SHOW hba_file;` when logged in as postgres) and https://www.postgresql.org/docs/12/libpq-envars.html also the link, @Hambone showed. – clamp Mar 15 '21 at 22:14
  • I'm looking these over, but how could i set the env variable or .pgpass file in order to require password? I can't find an answer to that here. – Leaozinho Mar 15 '21 at 22:16
  • You can't set them to require a password. But if they have been set accidentally, you won't need a password, because it is provided automatically. – clamp Mar 15 '21 at 22:18
  • I see, thanks. My question is that I want postgres to require a password for users that have a password specified for them. How can I do this? Right now I can log in as any user and never need a password. – Leaozinho Mar 15 '21 at 22:20
  • @Hambone I don't think I'm using the pgpass file. I can't find an instance of it anywhere. Any other possibilities? – Leaozinho Mar 15 '21 at 22:34
  • 1
    Please add `pg_hba.conf` to the question. – Laurenz Albe Mar 16 '21 at 00:40
  • 1
    Since you can log in, check `select * from pg_hba_file_rules` to make sure it is set how you want. – jjanes Mar 16 '21 at 01:06
  • Can you humor me and post your entire pg_hba.conf file? – Hambone Mar 16 '21 at 09:11
  • I actually think I have it working correctly now, but I would still be interested to hear if I got this right. Too much text to paste in here so check it out here: https://pastebin.com/raw/m3mXTMVy – Leaozinho Mar 16 '21 at 13:22

0 Answers0