Asks the running server for a single setting with SHOW password_encryption, issued as the postgres OS user through psql -X -tAc. That value decides how a password is hashed when CREATE ROLE or ALTER ROLE ... PASSWORD is issued. PASS only if the value is exactly scram-sha-256; anything else, including md5 and the legacy on, is a WARN with the live value quoted in the message.
Runs only when PostgreSQL is detected (HAS_PG=1) and reachable as the postgres user through root/sudo (PGOK=1); otherwise SKIP. It asks the running server (SHOW password_encryption), so it reports the value actually in effect, not what is written in postgresql.conf. It says nothing about how existing passwords are already stored - changing this setting does not re-hash them.
| Result | When | What it means |
|---|---|---|
| PASS | scram-sha-256 | Any password set from now on is stored with a modern salted hash. |
| WARN | Anything else (md5, or on on very old servers) | The live value is reported. New passwords are being written with a weak hash even if pg_hba.conf already asks for scram. |
| SKIP | Not accessible | Nothing was read. The setting is unknown, so the hashing algorithm is unverified rather than fine. |
password_encryption decides how new passwords are hashed in pg_authid. With md5, ALTER ROLE ... PASSWORD stores a crackable unsalted hash even if pg_hba.conf already says scram-sha-256. Default is scram-sha-256 since PostgreSQL 14. CIS PostgreSQL: "Ensure 'password_encryption' is set to 'scram-sha-256'".
- Clusters initialised before 14 and upgraded with
pg_upgradekeep the oldpostgresql.confvalue. - Changing the setting does not re-hash existing passwords. A
md5-hashed role cannot authenticate via ascram-sha-256HBA line; rehash before switching HBA. - Check current hash formats:
SELECT rolname, left(rolpassword,5) FROM pg_authid WHERE rolpassword IS NOT NULL;(SCRAMvsmd5).
ALTER SYSTEM SET password_encryption = 'scram-sha-256';SELECT pg_reload_conf();ALTER ROLE app PASSWORD 'same-or-new-password'; -- per rolesudo -u postgres psql -X -tAc 'SHOW password_encryption'# expected: scram-sha-256# Confirm stored hashes were actually migrated, not just the setting:sudo -u postgres psql -X -c "SELECT rolname, left(rolpassword,4) AS fmt FROM pg_authid WHERE rolpassword IS NOT NULL"# expected: every fmt is SCRAM (md5... means that role still has a legacy hash)HAS_PG=0orPGOK=0; see the debugging notes under PostgreSQL Auth Methods for how to test the probe.- Expected. The setting only governs hashes written from now on. The
pg_authidquery above shows which roles still carry anmd5hash; re-issueALTER ROLE <role> PASSWORD '...'for each. ALTER SYSTEMwritespostgresql.auto.conf, which is read last and therefore overridespostgresql.conf. If a config-management tool rewrites either file the value can flip back after a reload. Find out which file actually supplied the live value withSELECT name, setting, source, sourcefile FROM pg_settings WHERE name='password_encryption';.- Its stored hash and the HBA method now disagree. Re-hash that role, or temporarily keep the HBA line on
md5until every role is migrated.
