6

I am trying to peer authenticate some users using usermap. What I am trying to do is to map user mailreader as you can see:

postgres=# \du
 List of roles
 Role name | Attributes | Member of 
------------+------------------------------------------------+-----------
 mailreader | | {}
 postgres | Superuser, Create role, Create DB, Replication | {}

Into system's user root,dovecot,postfix. Therefore I edited my pg_ident.conf and put the following content:

mailmap dovecot mailreader
mailmap postfix mailreader
mailmap root mailreader

I also edited the pg_hba.conf and appended with the following content:

local mail all peer map=mailmap

When I try to connect via sudo psql -U mailreader -d mail command I get:

psql: FATAL: Peer authentication failed for user "mailreader"

error.

I also tried the following configuration:

local mail all ident map=mailmap

Without any progress.

May I have some help?

Edit 1

The logs regarding the error is:

2017年06月27日 19:10:10 UTC [1188-1] mailreader@mail LOG: provided user name (mailreader) and authenticated user name (root) do not match
2017年06月27日 19:10:10 UTC [1188-2] mailreader@mail FATAL: Peer authentication failed for user "mailreader"
2017年06月27日 19:10:10 UTC [1188-3] mailreader@mail DETAIL: Connection matched pg_hba.conf line 90: "local all all peer"
asked Jun 23, 2017 at 19:02
3
  • 1
    Did you restart the server, or reload the configuration files, after changing them? Commented Jun 26, 2017 at 16:38
  • 1
    Look in the postgres server log file for more detailed error reporting. The message returned to the client is intentionally vague, to avoid leaking information to an attacker. Commented Jun 26, 2017 at 16:39
  • @jjanes Yes I did that Commented Jun 27, 2017 at 19:15

1 Answer 1

5

In the end I had to comment the line:

local all all peer

Or to put it below the following line:

local mail all ident map=mailmap
answered Jun 27, 2017 at 19:13
1
  • Had the same problem. Basically, pg_hba.conf entries are taken in the order they are in the file, the first (not the better) match is used! Commented Jul 7, 2018 at 13:30

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.