是否可以在Postgresql中创建一个用户,而不提供纯文本密码(理想情况下,我想创建一个用户只提供密码用sha-256加密)?
我想做的是创建一个类似这样的用户:
CREATE USER "martin" WITH PASSWORD '$6$kH3l2bj8iT$KKrTAKDF4OoE7w.oy(...)BPwcTBN/V42hqE.';
有什么办法吗?
感谢您的帮助。
您可以提供已使用md5哈希的密码,如文档(
CREATE ROLE)中所述:
原文链接:https://www.f2er.com/postgresql/193364.htmlENCRYPTED UNENCRYPTED These key words control whether the password is
stored encrypted in the system catalogs. (If neither is specified,the
default behavior is determined by the configuration parameter
password_encryption.) If the presented password string is already in
MD5-encrypted format,then it is stored encrypted as-is,regardless of
whether ENCRYPTED or UNENCRYPTED is specified (since the system cannot
decrypt the specified encrypted password string). This allows
reloading of encrypted passwords during dump/restore.
这里缺少的信息是MD5加密的字符串应该是用户名连接的密码,加上开头的md5。
例如,使用密码foobar创建u0,知道md5(‘foobaru0’)是ac4bbe016b808c3c0b816981f240dcae:
CREATE USER u0 PASSWORD 'md5ac4bbe016b808c3c0b816981f240dcae';
然后u0将能够通过键入foobar作为密码登录。