编辑

编辑

我有一台主机(rhea),我已在该主机上安装了一个 postfix 来中继通过 DSL 连接从我的家庭服务器(tronics24)发送的电子邮件。

我已经生成了自签名证书:(在 rhea 上)

touch smtpd.key
chmod 600 smtpd.key
openssl genrsa 1024 > smtpd.key
openssl req -new -key smtpd.key -x509 -days 3650 -out smtpd.crt
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
sudo mv smtpd.key /etc/ssl/private/
sudo mv smtpd.crt /etc/ssl/certs/
sudo mv cakey.pem /etc/ssl/private/
sudo mv cacert.pem /etc/ssl/certs/

我已经测试过证书:

root@rhea:~# openssl s_client -showcerts -cert /etc/ssl/certs/smtpd.crt -key /etc/ssl/private/smtpd.key -starttls smtp -CAfile /etc/ssl/certs/cacert.pem -connect localhost:25

Postfix 回复 (/var/log/mail.log):

Apr 26 02:44:36 rhea postfix/smtpd[28778]: connect from localhost[127.0.0.1]
Apr 26 02:44:36 rhea postfix/smtpd[28778]: setting up TLS connection from localhost[127.0.0.1]
Apr 26 02:44:37 rhea postfix/smtpd[28778]: Anonymous TLS connection established from localhost[127.0.0.1]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)

我已经测试了SASL授权:

root@rhea:~# testsaslauthd -u <my-user> -p <my-pass>
0: OK "Success."

到目前为止一切正常。现在我尝试从我的家庭服务器进行连接。首先,我生成身份验证字符串:

printf '<my-user>\0<my-user>\0<my-pass>' | mmencode
dummydummy...==

myuser@tronics24 ~ » openssl s_client -starttls smtp -host rhea.<my-domain>.net -port 25
...
250 DSN
ehlo localhost
250-<mydomain>.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN dummydummy
535 5.7.8 Error: authentication failed: another step is needed in authentication

rhea 中的 Postfix 告诉我同样的事情:

Apr 26 02:17:10 rhea postfix/smtpd[11085]: connect from ip-82-143-145-145.myispdomain.com[82.143.145.145]
Apr 26 02:17:10 rhea postfix/smtpd[11085]: setting up TLS connection from ip-82-143-145-145.myispdomain.com[82.143.145.145]
Apr 26 02:17:10 rhea postfix/smtpd[11085]: Anonymous TLS connection established from ip-82-143-145-145.myispdomain.com[82.143.145.145]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
Apr 26 02:17:19 rhea postfix/smtpd[11085]: warning: ip-82-143-145-145.myispdomain.com[82.143.145.145]: SASL PLAIN authentication failed: another step is needed in authentication
Apr 26 02:17:35 rhea postfix/smtpd[11085]: lost connection after AUTH from ip-82-143-145-145.myispdomain.com[82.143.145.145]
Apr 26 02:17:35 rhea postfix/smtpd[11085]: disconnect from ip-82-143-145-145.myispdomain.com[82.143.145.145]

我对此感到很困惑,不知道还要寻找什么。您知道我还应该验证什么吗?

编辑

根据要求,我发布了 postfix 配置:

# Let's check the postconf configuration
root@rhea:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = rhea.<my-domain>.net, localhost.<my-domain>.net, localhost
myhostname = rhea.<my-domain>.net
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 82.143.145.145
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = 
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = 
smtpd_sasl_security_options = noanonymous
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom

输出postconf -a

root@rhea:~# postconf -a
cyrus
dovecot

这是输出saslfinger -s

root@rhea:~# saslfinger -s
saslfinger - postfix Cyrus sasl configuration Thu Apr 26 10:34:57 CEST 2012
version: 1.0.4
mode: server-side SMTP AUTH

-- basics --
Postfix: 2.5.1
System: Ubuntu 8.04.4 LTS (server)
Linux rhea.<my-domain>.net 2.6.32.2-xxxx-grs-ipv4-32 #1 SMP Tue Dec 29 14:41:18 UTC 2009 i686 GNU/Linux

server    : rps
ip        : 178.52.127.32
hostname  : rhea.<my-domain>.net

-- smtpd is linked to --
    libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb7593000)

-- active SMTP AUTH and TLS parameters for smtpd --
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = 
smtpd_sasl_security_options = noanonymous
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes


-- listing of /usr/lib/sasl2 --
total 716
drwxr-xr-x  2 root root  4096 2011-06-28 10:21 .
drwxr-xr-x 70 root root 36864 2011-06-22 17:30 ..
-rw-r--r--  1 root root 13568 2009-06-23 21:14 libanonymous.a
-rw-r--r--  1 root root   862 2009-06-23 21:14 libanonymous.la
-rw-r--r--  1 root root 12984 2009-06-23 21:14 libanonymous.so
-rw-r--r--  1 root root 12984 2009-06-23 21:14 libanonymous.so.2
-rw-r--r--  1 root root 12984 2009-06-23 21:14 libanonymous.so.2.0.22
-rw-r--r--  1 root root 15834 2009-06-23 21:14 libcrammd5.a
-rw-r--r--  1 root root   848 2009-06-23 21:14 libcrammd5.la
-rw-r--r--  1 root root 15320 2009-06-23 21:14 libcrammd5.so
-rw-r--r--  1 root root 15320 2009-06-23 21:14 libcrammd5.so.2
-rw-r--r--  1 root root 15320 2009-06-23 21:14 libcrammd5.so.2.0.22
-rw-r--r--  1 root root 46332 2009-06-23 21:14 libdigestmd5.a
-rw-r--r--  1 root root   871 2009-06-23 21:14 libdigestmd5.la
-rw-r--r--  1 root root 43020 2009-06-23 21:14 libdigestmd5.so
-rw-r--r--  1 root root 43020 2009-06-23 21:14 libdigestmd5.so.2
-rw-r--r--  1 root root 43020 2009-06-23 21:14 libdigestmd5.so.2.0.22
-rw-r--r--  1 root root 13574 2009-06-23 21:14 liblogin.a
-rw-r--r--  1 root root   842 2009-06-23 21:14 liblogin.la
-rw-r--r--  1 root root 13268 2009-06-23 21:14 liblogin.so
-rw-r--r--  1 root root 13268 2009-06-23 21:14 liblogin.so.2
-rw-r--r--  1 root root 13268 2009-06-23 21:14 liblogin.so.2.0.22
-rw-r--r--  1 root root 30016 2009-06-23 21:14 libntlm.a
-rw-r--r--  1 root root   836 2009-06-23 21:14 libntlm.la
-rw-r--r--  1 root root 29236 2009-06-23 21:14 libntlm.so
-rw-r--r--  1 root root 29236 2009-06-23 21:14 libntlm.so.2
-rw-r--r--  1 root root 29236 2009-06-23 21:14 libntlm.so.2.0.22
-rw-r--r--  1 root root 13798 2009-06-23 21:14 libplain.a
-rw-r--r--  1 root root   842 2009-06-23 21:14 libplain.la
-rw-r--r--  1 root root 13396 2009-06-23 21:14 libplain.so
-rw-r--r--  1 root root 13396 2009-06-23 21:14 libplain.so.2
-rw-r--r--  1 root root 13396 2009-06-23 21:14 libplain.so.2.0.22
-rw-r--r--  1 root root 22126 2009-06-23 21:14 libsasldb.a
-rw-r--r--  1 root root   873 2009-06-23 21:14 libsasldb.la
-rw-r--r--  1 root root 18080 2009-06-23 21:14 libsasldb.so
-rw-r--r--  1 root root 18080 2009-06-23 21:14 libsasldb.so.2
-rw-r--r--  1 root root 18080 2009-06-23 21:14 libsasldb.so.2.0.22

-- listing of /etc/postfix/sasl --
total 12
drwxr-xr-x 2 root root 4096 2011-07-01 11:19 .
drwxr-xr-x 3 root root 4096 2012-04-26 10:10 ..
-rw-r--r-- 1 root root   50 2011-07-01 11:19 smtpd.conf




-- content of /etc/postfix/sasl/smtpd.conf --
pwcheck_method: saslauthd
mech_list: plain login


-- content of /etc/postfix/sasl/smtpd.conf --
pwcheck_method: saslauthd
mech_list: plain login



-- active services in /etc/postfix/master.cf --
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
smtp      inet  n       -       -       -       -       smtpd
smtps     inet  n       -       -       -       -       smtpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
    -o smtp_fallback_relay=
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -   n   n   -   2   pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

-- mechanisms on localhost --
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN


-- end of saslfinger output --

答案1

要中继来自客户端的邮件,请使用提交,而不是普通的 SMTP。

您应该配置 postfix 以拒绝在端口 25 上提交(端口 25 仅用于 MTA <-> MTA 中继)。

有关详细信息,请参阅 master.cf 中带注释的提交示例;客户端应使用 STARTTLS 和 LOGIN 身份验证连接到端口 587(提交)。

所有其他邮件在提交时可能会被拒绝,即您设置

-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject

在提交监听器上。

然后测试实际的客户。

答案2

十年过去了,但有时调试时你仍然需要相同的命令。就我而言:

`openssl s_client -starttls smtp -quiet -crlf -connect server-name:587`

这导致了同样的错误(之后EHLO test):

`535 5.7.8 Error: authentication failed: another step is needed in authentication`

我设法在我的案例中找到了问题:字符串编码用户名和密码不完整,复制粘贴会自动排除尾随的非字母数字字符(在我的情况下为“=”)。因此,在详细介绍 SASL 和组件之前,请先进行简单检查:检查您的输入是否完整。

相关内容