First configure your /etc/postgresql/12/main/pg_hba.conf to use pam.
1 2 3 4 5 6 7 8
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 192.168.0.0/16 pam pamservice=postgresql
Create a roles
For each user that is going to login on postgresql create a role and assign permissions.
1
CREATE ROLE "jrgcombr" SUPERUSER NOCREATEDB CREATEROLE INHERIT LOGIN;