PostgreSQL – Roles Without Linux Accounts

authenticationpostgresqlpsqlrole

Basic question:

what I'm reading describes how to create linux users in parallel with postgresql roles.

However, I don't see the value in creating any of these users in linux – I just want to create a postgresql role – and login to that from my application – or when running psql from the terminal using my own login – but in the role of the project.

e.g. – if the project is 'foo' – I want to have the psql -U foo, but no 'foo' user under linux. After all – what's the point? It's a role purely for psql – not for linux.

Is this possible in Postgresql – and if so – how do I do this?

I've trivially created a postgresql user role – without a linux account – but then I cannot ever -U role, as I get an error around peer authentication.

So – I assume I need to change how postgresql is handling permissions – and that's where I'm too green with postgresql to know what I'm doing there.

Perhaps a pointer to a clear little document discussing authentication modes or connection modes and setup for postgresql would help me resolve my issues?

Best Answer

Either don't use peer authentication, or do use it but with a user mapping (specified in pg_ident.conf) which declares which db users each OS user is allowed to connect as.