Sobes.tech
Junior — Middle

Where and how is password encryption configured in PgBouncer settings?

sobes.tech AI

Answer from AI

In PgBouncer, password encryption on the client side is not configured directly, as PgBouncer acts as a proxy for PostgreSQL. However, for storing user passwords in the userlist.txt file, hashed passwords can be used.

To set password encryption:

  1. In the userlist.txt file, passwords can be specified as MD5 hashes, for example:

    "username" "md5<md5hash>"
    

    where <md5hash> is the MD5 hash of the password in PostgreSQL format.

  2. In the pgbouncer.ini configuration file, the auth_type parameter determines the authentication method, for example:

    • auth_type = md5 — for using MD5 password hashes.
    • auth_type = trust — without a password.
  3. The auth_file parameter specifies the path to the file with users and passwords (usually userlist.txt).

Thus, password encryption is indirectly set through the format of stored passwords in userlist.txt and the authentication method chosen in pgbouncer.ini.

Example line in userlist.txt:

"user1" "md5c3ab8ff13720e8ad9047dd39466b3c89"

where c3ab8ff13720e8ad9047dd39466b3c89 is the MD5 hash of the password.