Install Postgresql 13 on RHEL 8. Configure scram-sha-256 password authentication.

# dnf module list | grep postgres
# dnf module install postgresql:13

2. Initialize database

# which postgresql-setup
# postgresql-setup --initdb

3. Change password for os user postgres auto created after installing postgresql

# passwd postgres

4. Enable and start postgresql service

# systemctl enable postgresql
# systemctl start postgresql
# systemctl status postgresql

5. Modify postgresql.conf file

#vim /var/lib/pgsql/data/postgresql.conflisten_addresses = '*'
password_encryption = scram-sha-256

6. login to postgres database using peer authentication.

# su - postgres
# psql
postgres=# \conninfo

7. Change postgres database user password and password encryption method

postgres=# \password
postgres=# set password_encryption TO 'scram-sha-256';

8. Change authentication type to scram-sha-256 in pg_hba.conf file

# cd /var/lib/pgsql/data
# vim pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections only
local all all scram-sha-256
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all scram-sha-256
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256

9. Restart postgresql service and login using password authentication

# systemctl restart postgresql
$ psql -U postgres -d postgres

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu Pratap

Himanshu Pratap

System Administrator and Full stack web developer.