【问题标题】:PgBouncer configure auth_user without plain text passwordPgBouncer 配置没有明文密码的 auth_user
【发布时间】:2022-12-20 18:25:12
【问题描述】:

我正在研究 pgBouncer 的配置,我能够让它与 auth_query 一起工作。是否有可能以某种方式为 auth_user 加密密码? 最初我尝试使用 SCRAM 哈希,但随后连接失败。我读过 md5 是可能的,但我已经在服务器上配置了 SCAM。

;
; pgbouncer configuration example
;
[databases]
test5432 = port=5432 host=localhost auth_user=myauthuser
alin = port=5435 host=localhost auth_user=myauthuser5435
[pgbouncer]
listen_addr = *
listen_port = 6432
admin_users = postgres
;stats_users = monitoring userid
auth_type = scram-sha-256
; put these files somewhere sensible:
auth_query = SELECT usename, passwd FROM user_search($1)
auth_file = users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
server_reset_query = DISCARD ALL;
; default values
pool_mode = session
default_pool_size = 20
log_pooler_errors = 1

用户.txt

 "postgres" "SCRAM-SHA-256$4096:Ou4b7GtxwKdQ2NnKwHUxoQ==$RT+nGDekJIzK4L9wxGY4W7$
 "myauthuser" "asdf"
 "myauhuser5345" "asdf"

我正在尝试运行:

psql -h 192.168.1.59 -p 6432 -U alinka test5432

【问题讨论】:

  • 在数据库服务器机器上安装 pgBouncer 并为 auth_user 使用本地 trust 身份验证。如果那不可行,请使用 SSL 认证身份验证。
  • @LaurenzAlbe 我从users.txt 中删除了myauthuser,并将local all myauthuser,postgres trust 添加到pg_hbf.conf,但现在我在pgbouncer.log - WARNING server login failed: FATAL password authentication failed for user "myauthuser" 中收到一条错误消息。 Postgres 托管在我笔记本电脑上的 VM 上,我尝试从我的笔记本电脑连接。不确定这是否有所作为。使用端口 5432 的直接连接工作正常。
  • 那么就不是local了,一定不要忘记pg_hba.conf里面有个单机掩码。
  • 假设明文密码是Pk(dw7*ajQ(1xlIv4M.E6sJzI。你会把它加密成什么,这样做的意义何在?它要么拥有允许其登录的东西,要么没有。
  • local 是通过套接字文件而不是 IP 地址连接时使用的内容。所以它将用于host=/tmphost=/var/run/postgresql

标签: postgresql pgbouncer postgresql-14


【解决方案1】:

我能够在我的 pgbouncer 中使用 scram-sha-256 加密密码。 当您在中指定 scram-sha-256 时配置文件

auth_type = scram-sha-256

在你的用户.txt你需要使用 scram 来加密你的 auth_user 的密码 例如

 "myauthuser" "SCRAM-SHA-256$4096:blablabla"
 "myauhuser5345" "SCRAM-SHA-256$4096:blablabla$"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-25
    • 2019-03-25
    • 2022-12-01
    • 2018-12-03
    • 2021-04-28
    • 1970-01-01
    • 2012-10-12
    • 2019-03-08
    相关资源
    最近更新 更多