我不是 Postfix 专家...我在 Debian 11.8 上的 posfix 3.5 中遇到了身份验证问题。
我添加了一个测试用户:
# saslpasswd2 -c test
Password: test
使用 swaks 测试 Postfix 身份验证时出现以下错误:
# swaks --to root --server 172.31.0.69:25 --auth LOGIN
Username: test
Password: test
535 5.7.8 Error: authentication failed: authentication failure
*** No authentication type succeeded
日志:
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-xxx.localdomain
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-PIPELINING
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-SIZE 10240000
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-VRFY
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-ETRN
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-AUTH=CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-ENHANCEDSTATUSCODES
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-8BITMIME
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250-DSN
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 250 CHUNKING
postfix/smtpd[3144881]: watchdog_pat: 0x55af645786d0
postfix/smtpd[3144881]: < unknown[172.31.0.69]: AUTH LOGIN
postfix/smtpd[3144881]: xsasl_cyrus_server_first: sasl_method LOGIN
postfix/smtpd[3144881]: xsasl_cyrus_server_auth_response: uncoded server challenge: Username:
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 334 VXNlcm5hbWU6
postfix/smtpd[3144881]: < unknown[172.31.0.69]: dGVzdA==
postfix/smtpd[3144881]: xsasl_cyrus_server_next: decoded response: test
postfix/smtpd[3144881]: xsasl_cyrus_server_auth_response: uncoded server challenge: Password:
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 334 UGFzc3dvcmQ6
postfix/smtpd[3144881]: < unknown[172.31.0.69]: dGVzdA==
postfix/smtpd[3144881]: xsasl_cyrus_server_next: decoded response: test
postfix/smtpd[3144881]: warning: unknown[172.31.0.69]: SASL LOGIN authentication failed: authentication failure
postfix/smtpd[3144881]: > unknown[172.31.0.69]: 535 5.7.8 Error: authentication failed: authentication failure
通过 testsaslauthd 进行的身份验证测试有效:
# testsaslauthd -s smtp -u test -p test
0: OK "Success."
与 telnet 相同:
# telnet 172.31.0.69 25
Trying 172.31.0.69...
Connected to 172.31.0.69.
Escape character is '^]'.
220 xxx.localdomain ESMTP Postfix (Debian/GNU)
HELO xxx.com
250 xxx.localdomain
AUTH LOGIN
334 VXNlcm5hbWU6
dGVzdAo=
334 UGFzc3dvcmQ6
dGVzdAo=
535 5.7.8 Error: authentication failed: authentication failure
[主文件]
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost = XXX
smtp_fallback_relay = XXX
mynetworks = 127.0.0.0/8
#inet_interfaces = loopback-only
inet_protocols = ipv4
recipient_delimiter = +
inet_interfaces = all
smtpd_relay_restrictions = permit_mynetworks
permit_sasl_authenticated reject
# auth
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
cyrus_sasl_config_path = /etc/postfix/sasl
debug_peer_list = 172.31.0.69
[sasl/smtpd.conf]
pwcheck_method: saslauthd
auxprop_plugin: sasldb
aslech_list: CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
[/etc/default/saslauthd]
START=yes
MECHANISMS="sasldb"
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"
编辑1
[/etc/邮件名称]
backup6
用户:
# sasldblistusers2
test@backup6: userPassword
编辑2
-r 在 saslauthd 配置中删除。根据文档,“-r 将领域与登录名结合起来(中间用“@”符号)。例如,登录名:“foo”领域:“bar”将作为登录名:“foo@bar”传递。请注意,领域仍将被传递,这可能会导致意外行为。“
[/etc/default/saslauthd]
START=yes
MECHANISMS="sasldb"
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
PARAMS="-m /var/spool/postfix/var/run/saslauthd"
然后 swaks 开始工作:
# swaks --to root --server 172.31.0.69:25 --auth LOGIN
Username: test@backup6
Password: test
[...]
235 2.7.0 Authentication successful
但是 telnet 仍然失败,用户名是 test@backup6 (base64 编码)。
答案1
正如评论中所说,用户名和该领域被发送到 SASL 库。
-r
已从 saslauthd 配置中删除(意外行为;领域仍在发送),并且smtpd_sasl_local_domain
可以强制测试行为。
使用此配置,swask 可以进行身份验证,telnet 也可以。对于 telnet,错误是 base64 编码错误(抱歉!)。提醒一下,-n
在 echo 中使用不带换行符的 base64 编码:
echo -n $USERNAME | base64