Skip to content

Instantly share code, notes, and snippets.

@kravietz
Last active January 21, 2020 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kravietz/217179e497075509cae060641443b1ca to your computer and use it in GitHub Desktop.
Save kravietz/217179e497075509cae060641443b1ca to your computer and use it in GitHub Desktop.
Switch PostgreSQL 10 to new strong SCRAM-SHA-256 password authentication
postgres@tyler:~$ psql
psql (10.5 (Ubuntu 10.5-1.pgdg16.04+1))
Type "help" for help.
postgres=# show password_encryption;
password_encryption
---------------------
md5
(1 row)
postgres=# SET password_encryption = 'scram-sha-256';
SET
postgres=# \password webapp
Enter new password:
Enter it again:
postgres=# ALTER USER "webapp" WITH PASSWORD 'PLAINTEXT_USER_PASSWORD_HERE';
ALTER ROLE
postgres=# select * from pg_user;
usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
------------+----------+-------------+----------+---------+--------------+----------+----------+-----------
postgres | 10 | t | t | t | t | ******** | |
webapp | 16384 | t | f | f | f | ******** | |
(2 rows)
postgres=# show password_encryption;
password_encryption
---------------------
scram-sha-256
(1 row)
postgres=#
Also replace occurences of "md5" with "scram-sha-256" in pg_hba.conf and restart PostgreSQL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment