4

From what I read in my pg_hba.conf, I'm inferring that, to make sure I'm prompted for a password for the postgres user, I should edit pg_hba.conf's first two entries' method from the current 'peer' to either 'password' or 'md5', but I don't want to break things if that's wrong. Am I on the right track? Or missing something obvious?

Anyway, more details-

After installing postgres 9.4 on debian, I changed the postgres user's password by doing this-

postgres=# \password postgres

...and entering in the new password twice.

Then I exited postgres (Ctrl+D), then restarted the server from bash-

sudo service postgresql restart

When I log back into postgres (sudo -u postgres psql), I'm not prompted for the new password. I just get-

psql (9.4.9)
Type "help" for help

postgres=#

Also, the .pgpass file is in my home directory, but it's empty. Finally, first two lines of pg_hba.conf are

local   all        postgres      [blank]   peer
local   all        all           [blank]   peer
2
  • @zerkms There's no requirement for peer auth to be enabled, and it can be disabled. But you'll want something if you want to be able to log in. Commented Sep 13, 2016 at 4:31
  • @CraigRinger something that has sufficient privileges yep. And various tools sometimes rely on its presence (eg backup scripts). Commented Sep 13, 2016 at 4:33

1 Answer 1

10

Setting a password only provides the password for authentication methods that require it. It does not add the requirement that the password be specified for login.

Whether a password is required is controlled by pg_hba.conf. The peer auth mode does not require a password, it allows a user to log in if their unix username is the same as the postgres username they're trying to connect as.

Try md5 auth if you want password authentication.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.