Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On Fedora 12, I'm setting up a test database for myself, and pg_hba.conf contains the following by default:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          ident
# IPv6 local connections:
host    all         all         ::1/128               ident

I want to enable md5 logins so the PostgreSQL user named 'foo' can access the database named 'foo'. However, when I add this line and restart postgres:

local   foo         foo                               md5

Running psql -U 'foo' with my regular user account still yields the message:

psql: FATAL:  Ident authentication failed for user "foo"

I have to remove the first local line (which has ident) before I can log in via md5 to 'foo'.

How can I enable md5 authentication for 'foo' while keeping ident authentication like I already have?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

http://www.postgresql.org/docs/8.4/interactive/auth-pg-hba-conf.html indicates that the order of entries maters, specifically:

Since the pg_hba.conf records are examined sequentially for each connection attempt, the order of the records is significant. Typically, earlier records will have tight connection match parameters and weaker authentication methods, while later records will have looser match parameters and stronger authentication methods. For example, one might wish to use trust authentication for local TCP/IP connections but require a password for remote TCP/IP connections. In this case a record specifying trust authentication for connections from 127.0.0.1 would appear before a record specifying password authentication for a wider range of allowed client IP addresses.

(so try reversing the order - put the line you are adding at the top)

share|improve this answer
    
Thanks, that clears a lot up! –  Joey Adams Feb 15 '10 at 3:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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