PostgreSQL multiple authentication methods PostgreSQL multiple authentication methods postgresql postgresql

PostgreSQL multiple authentication methods


Nope. Only one auth method is supported for any given configuration.

I'd love it if Pg could support fall-back authentication, where if an ident check fails it allows md5 auth instead. It doesn't support this at the moment, though, and I suspect (I haven't verified) that a protocol change would be required to support it.

What you can do is store the password in a $HOME/.pgpass file for the postgres system user. Give it mode 0600 so it's only readable by the postgres user and by root, both of whom can get direct access to the database files and configuration anyway. That way you get easy admin and md5 auth. On some systems you may have to set and create a home directory for the postgres user before you can do this. See getent passwd postgres to see if if the postgres user has a homedir and if so, where it is.

(UPDATE: used to read $HOME/.psqlrc - which is useful, but .pgpass is suitable for password storage)