This tool build a PostgreSQL MD5 password hash starting from a valid login and password.
It is an helper tool useful when you are trying to configure PgBouncer and its relative auth_file
config property.
PgBouncer companion script mkauth.py, that creates a valid auth_file
starting from a PostgreSQL instance, assumes that you have access to pg_shadow
, which is not always true (an example is Amazon RDS for PostgreSQL, the master user cannot access such informations).
The formula to obtain a valid hash is quite simple:
hash = 'md5' + md5(password + login)
but, when you are working with CLI you hope for a quick 'n' dirty script that will do the job for you.
pgbpasswd
produces the hash requested by PgBouncer starting from a valid login and password and optionally it appends the data to an existing auth_file
(or create it if is missing).
pgbpasswd <login> <password>
will output the hash and the row that could be appended to auth_file
to standard output.
pgbpasswd <login> <password> -f <filename>
will output the hash to standard output and append a line to auth_file
with login and hashed password.
pgbpasswd
is written in Go and it has a Makefile
that handles the build procedure.
Assuming you have a valid installation of Go in place and autotools installed, the command to build is:
make
the compiled command will be into the build
directory of the project (the script is statically linked and ready to be deployed in place).