我在 postfix 上尝试验证用户/密码 saslauthd 时遇到一个奇怪的问题
mail.log 中的相关行
Feb 14 16:06:21 smswtc postfix/smtpd[3577]: warning: SASL authentication failure: Requested identity not authenticated identity
Feb 14 16:06:21 smswtc postfix/smtpd[3577]: warning: unknown[192.168.10.134]: SASL PLAIN authentication failed: authentication failure
奇怪的是(来自postfix的smtpd进程的strace):
read(10, "AUTH PLAIN fXOlcM5hbWLAc21wcABmaVFh\r\n", 4096) = 37
socket(PF_LOCAL, SOCK_STREAM, 0) = 12
connect(12, {sa_family=AF_LOCAL, sun_path="/var/run/saslauthd/mux"}, 110) >= 0
**writev(12, [{"\0\4user\0\4password\0\4smtp\0\6realm", 26}], 1) = 26
read(12, "\0\2", 2) = 2
read(12, "OK", 2) = 2**
close(12) = 0
sendto(8, "<20>Feb 14 16:04:58 postfix/smtpd[3395]: warning: SASL authentication failure: Requested identity not authenticated identity", 124, MSG_NOSIGNAL, NULL, 0) = 124
sendto(8, "<20>Feb 14 16:04:58 postfix/smtpd[3395]: warning: unknown[192.168.10.134]: SASL PLAIN authentication failed: authentication failure", 131, MSG_NOSIGNAL, NULL, 0) = 131
看起来 saslauthd 确实向 postfix 回复了 OK!
也可以从 saslauthd 日志(调试)中获取
saslauthd[3169] :do_auth : auth success: [user=user] [service=smtp] realm="realm"] [mech=shadow]
saslauthd[3169] :do_request : response: OK
还清楚的是 saslauthd 对用户进行了身份验证。所以我不太明白为什么 postfix 会抱怨 SASL 身份验证失败(参见上面的 postifix mail.log)
文件:
root@xxx:~# cat /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
root@smswtc:~# cat /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = smswtc
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = wtc99.com, localhost, localhost.localdomain, localhost
relayhost = out.alice.sm
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtpd_sasl_local_domain = ""
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
relay_domains = wtc99.com
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
答案1
对于 SASL 身份验证PLAIN
需要用户名和密码,但我在您的 中看不到它/etc/postfix/main.cf
。请尝试将其添加到/etc/postfix/sasl_passwd
:
[relayhost.com]:relayPort UserName@mailDomain:Password
然后运行postmap /etc/postfix/sasl_passwd
,并添加/etc/postfix/main.cf
以下行:
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous