DEBUG.WIKI
野草云;香港 200Mbps 峰值;不限月流量 · BGP VPS;查看套餐 →
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证
V.PS:让项目靠近用户,亚太、欧洲、北美 KVM VPS

解决 Odyssey 报错 SCRAM-SHA-256 client authentication failed 密码协议不匹配修复

排查 客户端使用 SCRAM 认证连接 Odyssey 报 scram-sha-256 authentication failed 或 Unsupported authentication type,分析 密码认证模式转换与用户映射。

问题现象

PostgreSQL 14 开启 SCRAM-SHA-256 后,客户端通过 Odyssey 代理时认证失败:

fatal: password authentication failed for user 'webapp'
Odyssey log: [auth] authentication failure: unsupported or mismatch scram auth mechanism

触发根因

  1. Odyssey 在早前版本中对客户端原生的 SCRAM-SHA-256 透传需要显式配置支持;
  2. Odyssey 内部配置的认证类型(authentication)声明为了 md5 或 clear_text,与客户端发出的 SCRAM 挑战报文产生冲突。

解决步骤

在 Odyssey 中正确声明 scram-sha-256 密码鉴权

在 odyssey.conf 数据库或用户规则块中明确指定:

database default {
    user "webapp" {
        authentication "scram-sha-256"
        password "SCRAM-SHA-256$4096:5a...==:1b...=="
        pool "transaction"
    }
}

或者让 Odyssey 作为透明透传代理

在用户配置中配置透传至后端数据库验证:

user "webapp" {
    authentication "none"
    storage_password "my_actual_password"
    pool "transaction"
}

验证确认

重载 Odyssey 进程:

客户端顺利通过 SCRAM 握手完成安全认证与查询执行。