In PostgreSQL, I have the following configuration in pg_hba.conf
:
local all sec_eng scram-sha-256 host all sec_eng scram-sha-256 hostssl all app_server 192.168.1.0/32 scram-sha-256 clientcert=verify-full
There are no other configuration lines.
When I try to connect to PostgreSQL using sudo psql -U sec_eng
, the client authenticates me as a peer
, and does not prompt me for any password, and therefore the authentication fails.
If I try sudo psql -U sec_eng -h localhost
I am authenticated as Ident
, am not prompted for a password, and therefore the authentication fails.
What am I doing wrong here? How can I connect to PostgreSQL through a Unix Socket, using my username and a password?
pg_hba.conf
is actually the one which is used? Runshow hba_file;
orselect * from pg_settings where name='hba_file';
as the user who is member ofpg_read_all_settings
role, or as a superuser (postgres
), it will show the path. The latter also will tell you the source of the configuration that instructs it to use that file instead of the default./var/lib/pgsql/17/data/pg_hba.conf
, and PostgreSQL was reading from/var/lib/pgsql/data/pg_hba.conf
. Thank you very much, mister Kipriyanov. I have a question, if you please. If PostgreSQL was reading from the second path, what's the first path for? (I have not ordered PostgreSQL to read from the second, nor did I create the17/
directory.)