HBA (Host Based Authentication) file in PostgreSQL server
How HBA works /Validates
HBA (Host Based Authentication) file in PostgreSQL server
How HBA works /Validates
->Type: Local /Host
· LOCAL if we are making connection to the PostgreSQL from local server where PostgreSQL is running.
*Type* Database User Address Method
local all all peer
· Host -> To allow the remote connection, we use host
*Type* Database User Address Method
host all all 127.0.0.1/32 peer
->Database :
ALL à it allows to access/connect all the databases in a postgresql instance
Type Database User Address Method
local all all peer
Defined / User defined databases à it allows access only for the testdb database
Type **Database User Address Method**
local test dB all peer
->User:
All-> it allows all the users to access the databases
Type Database **User Address Method**
host all all 127.0.0.1/32 peer
pguser-> it allows access the databases only to pguser1
Type Database **User Address Method**
host all pguser 127.0.0.1/32 trust
->Address:
<BLANK> when you are connecting from local server (type=local)
Type Database User **Address Method**
local all all <blank > peer
<IP Address/IP Ranges/client ip range>->it allows the connection from a particular client ip/client ip range
Type Database User **Address Method**
Host all all 127.0.0.1/32 trust
->Method
1.Peer->it allows only if the os user and db user are same
**Type Database User Address **Method
host pguser1 all 127.0.0.1/32 peer
- Trustàallows to connect with out password
**Type Database User Address **Method
host pguser1 all 127.0.0.1/32 trust
3.scram-sha-256/md5à must enter the password and it is very strict authentication (advanced than md5)
**Type Database User Address **Meth; od
host pguser1 all 127.0.0.1/32 scram-sha-256/md5
Change the Method to scram-sha-256 allow the access with password:
4.reject -> it wont allows the connections
**Type Database User Address **Method
host pguser1 all 127.0.0.1/32 reject
Mkae sure reload the server after conifiguration
메타데이터
- post_id
- c22ee1852ef2
- slug
- hba-host-based-authentication-file-in-postgresql-server-c22ee1852ef2
- url
- https://medium.com/@sandeepsam0909/hba-host-based-authentication-file-in-postgresql-server-c22ee1852ef2
- canonical_url
- https://medium.com/@sandeepsam0909/hba-host-based-authentication-file-in-postgresql-server-c22ee1852ef2
- author_url
- https://medium.com/@sandeepsam0909
- status
- ok
- fetched_at
- 2026-06-23 06:34:20