QA
Intermediate LevelPostgreSQL

What is SCRAM-SHA-256 authentication and how does pg_hba.conf enforce access controls?

❓ Interview Prompt: Explain `pg_hba.conf` (Host-Based Authentication), authentication methods (`trust`, `peer`, `md5`, `scram-sha-256`), and password security.

'pg_hba.conf' controls client connection access rules based on connection type, client IP, database, and user:

Authentication Methods:

•
'scram-sha-256' (Recommended): Modern cryptographic password authentication algorithm.
•
'md5' (Deprecated): Legacy hash vulnerable to rainbow table attacks.
•
'peer': Uses OS user credentials for local Unix socket logins.

Code Implementation Example

conf
# pg_hba.conf security rules
# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     peer
host    all             all             10.0.0.0/8              scram-sha-256
💡Configuring client authentication rules in pg_hba.conf using scram-sha-256.
🎯 Interview Key Takeaway

Always use scram-sha-256 authentication in pg_hba.conf for secure password verification.

#pg_hba.conf#SCRAM-SHA-256#Security#Authentication#Intermediate
Back to all PostgreSQL Questions→

More PostgreSQL Interview Questions

Beginner LevelPostgreSQL

How to use pgvector in PostgreSQL for vector similarity search with HNSW indexes?

Beginner LevelPostgreSQL

What is PostgreSQL architecture and how do client backends connect via process fork model?

Beginner LevelPostgreSQL

What special built-in data types exist in PostgreSQL (JSONB, UUID, ARRAY, INET, TEXT)?