Skip to content

fillmore-labs/pgpasswd

Repository files navigation

Encrypted PostgreSQL Password

070c600f14498cd3d708e16c2df30e390d948c7fa9cd1a3fed

Table of Contents

Purpose

The PostgreSQL documentation of CREATE ROLE mentions:
If the presented password string is already in MD5-encrypted or SCRAM-encrypted format, then it is stored as-is regardless of password_encryption (since the system cannot decrypt the specified encrypted password string, to encrypt it in a different format).

Which is not only useful during dump and restore, but also when initializing a new installation.

This is a simple tool to create SCRAM-SHA-256 encrypted passwords.

Usage

./pgpasswd.sh user pass

outputs

CREATE ROLE "user" WITH
  LOGIN
  PASSWORD 'SCRAM-SHA-256$4096:...';

which can be fed directly into PostgreSQL.

References