If you need to pre-generate a scram-sha256
password hash for use with postgres, e.g. for using it with config management like puppet, pre-generating the password hash can be done in a small oneliner on any machine that has postgres installed:
$ createuser -e dummy --pwprompt
Enter password for new role:
Enter it again:
SELECT pg_catalog.set_config('search_path', '', false);
CREATE ROLE dummyuser PASSWORD 'SCRAM-SHA-256$4096:QJQsradJegC1DjzhWFAUEw==$l60VVp5kOM1YzLBqv7mRxZ7A0J31dQgV69Ugzkj/Frc=:ZhqSB6yXeV+Cf+5Q32fylOoukYJrutprcDmzYwM3pTY=' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;
and the salted password hash can be retrieved between the single quotes after PASSWORD
.
This will not actually create a user on your postgres cluster. The -e
option means echo
.