Is it possible to create a user in PostgreSQL without providing the plain text password (ideally, I would like to be able to create a user providing only its password crypted with sha-256) ?
What I would like to do is to create a user with something like that :
CREATE USER "martin" WITH PASSWORD '$6$kH3l2bj8iT$KKrTAKDF4OoE7w.oy(...)BPwcTBN/V42hqE.';
Is there some way to do that ?
Thank you for your help.
Much easier way to to this is:
CREATE USER u0 PASSWORD 'foobar';
Gives passwd:
md5ac4bbe016b808c3c0b816981f240dcae
You may provide the password already hashed with
md5
, as said in the doc (CREATE ROLE):The information that's missing here is that the MD5-encrypted string should be the password concatened with the username, plus
md5
at the beginning.So for example to create
u0
with the passwordfoobar
, knowing thatmd5('foobaru0')
isac4bbe016b808c3c0b816981f240dcae
:and then u0 will be able to log in by typing
foobar
as the password.I don't think that there's currently a way to use
SHA-256
instead ofmd5
for PostgreSQL passwords.I'm not aware of a way to override the default md5 encryption of passwords, but if you have a ROLE (aka "USER") that has an already md5-encrypted password it appears that you can supply that. Verify this using pg_dumpall -g (to see the globals from the cluster) Eg.
Docs for CREATE ROLE