PG_ENC(1)

πŸ’– PG_ENC πŸ’–

okay bestie, so this is pg_enc, the AES256 password encryption utility from the pgpool-II 4.7.2 documentation set. she encrypts your database passwords and she does it flawlessly, no cap. let's get into it 🫢


✨ SYNOPSIS ✨

pg_enc [option...] -p

pg_enc [option...] password

like, two whole moods. either you're prompting for the password, or you're just handing it over directly. choose your fighter πŸ’…


🌸 DESCRIPTION 🌸

pg_enc is the AES256 password encryption utility. that's it. that's the whole job. she encrypts passwords with AES256 and she's iconic for it. periodt. πŸ‘‘


πŸŽ€ OPTIONS πŸŽ€

every single flag, right here, no skips, we don't gatekeep:

  • -k KEY_FILE, --key-file=KEY_FILE β€” sets the path to the encryption key file. the default is the .pgpoolkey file chillin' in your home directory, but you can override that with the PGPOOLKEYFILE environment variable. iykyk. πŸ”‘
  • -K ENCRYPTION_KEY, --enc-key=ENCRYPTION_KEY β€” the encryption key that gets used for encrypting database passwords. just, like, hand it over directly.
  • -f CONFIG_FILE, --config-file=CONFIG_FILE β€” specifies the pgpool.conf file. yes, that one. πŸ—‚οΈ
  • -i INPUT_FILE, --input-file=INPUT_FILE β€” specifies the file containing username and password pairs. very organized of you honestly.
  • -p, --prompt β€” prompts for the database password using standard input. the classic. the main character entrance. ✨
  • -P, --prompt-for-key β€” prompts for the encryption key using standard input. (note: lowercase -p is the password, uppercase -P is the key. do not mix them up bestie, i am begging 😭)
  • -m, --update-pass β€” creates an encrypted password entry in the pool_passwd file. the whole point, honestly. πŸ”₯
  • -u your_username, --username=your_username β€” creates the pool_passwd entry for the database user called your_username. put a name on it.
  • -h, --help β€” prints the help for pg_enc. when in doubt, -h it out. πŸ¦‹

⚠️ Note (important, read this)

If you are providing the password as an argument to pg_enc and the password contains a "$" character, you must escape it.

like, seriously. the shell will eat that $ alive and not tell you. πŸ’€

for example, if you want to use "ABC$123" as password,

pg_enc -m -f /path/to/pgpool.conf -u username ABC\$123

see the backslash? yeah. that's the whole thing.


🌈 EXAMPLE 🌈

here's an example output, so you know what you're getting into:

pg_enc -p
db password: [your password]

or

./pg_enc foo
trying to read key from file /home/pgpool/.pgpoolkey

jglid1QRgiCl/vfhHUDyVA==
pool_passwd string: AESjglid1QRgiCl/vfhHUDyVA==

look at that output. clean. crisp. ate. πŸ“

pg_enc can be used for pool_passwd passwords with:

pg_enc -m -f /path/to/pgpool.conf -u username -p
db password: [your password]

which will add an entry for username with the password given. easy. iconic. done. πŸ’…


🧚 reading pairs from a file (the avoid-the-prompt route)

To avoid password prompt or password in command parameter, pg_enc can read user name:password pairs from file. It will add all user names and encrypted password to pool_passwd authentication file.

$ cat users.txt
username1:secretpassword1
username2:secretpassword2

$ pg_enc -m -f /path/to/pgpool.conf -i users.txt
trying to read key from file /home/pgpool/.pgpoolkey
trying to read user:password pairs from file users.text

$ cat /path/to/pool_passwd
username1:AESrx5QdpGyW/+4CB80KWtwhg==
username2:AESUAdohy7nCUhWliRI9WiYQA==

batch processing your credentials? obsessed. no typing, no escaping drama, no stress. the file does the work for you. πŸ™ˆ


and that's the whole page bestie. this was pg_enc from the pgpool-II 4.7.2 documentation, dated 2023, filed under PG_ENC(1). go encrypt something and be free. πŸ’œβœ¨

πŸ“¦ where this page comes from