Zakir Hossain
Zakir Hossain

Reputation: 444

How to Control PostgreSQL Password authentication both Front end and Command line in Windows 10 and Redhat (Linux)?

Recently I'm using PostgreSQL9.2 both in Windows 10 and Redhat (Linux).
But now I'm little concern about PostgreSQL access authentication.
Late me explain...

When i first installed PostgreSQL in my system i used two different password for two log in role postgres (default) and adempiere (created). In Redhat i use to psql -h localhost -U postgres db_name and psql -h localhost -U adempiere db_name command. Sometime this command wants password sometime not.

Recently I have used ALTER USER postgres WITH PASSWORD 'new_password'; and ALTER USER adempiere WITH PASSWORD 'new_password'; command to change. But here is an another problem. After changed my password when i get database access with psql -h localhost -U adempiere db_name command, i can access with both old_passwod and new_password.

Now what can i do for Strong authentication in my Database both Windows 10 and Redhat (linux) ?

Here is part of my pg_hba.conf for reference:

# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records.  In that case you will also need to make PostgreSQL
# listen on a non-local interface via the listen_addresses
# configuration parameter, or via the -i or -h command line switches.



# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
host    all             all             192.168.2.151/32            trust
host    all             all             192.168.2.5/32            trust
host    all             all             192.168.2.6/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                md5
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

Upvotes: 0

Views: 653

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247665

To force password authentication for every connection, replace trust with md5 everywhere in pg_hba.conf and reload the server.

It is dangerously negligent to use PostgreSQL 9.2. Use a later version. For one, this will offer the more secure scram-sha-256 hashing method for password authentication.

Upvotes: 2

Related Questions