大网数据广告活动
服务器运维问答

SASL authentication failure: Password verification failed even when it works with testsaslauthd

· 52CE 我爱测

I'm having some trouble configuring client authentication using saslauthd and postfix on ubuntu 22.04. The issue is that users are not getting authenticated although the user exists. It's my first time setting up postfix and sasl…

问题原文

原帖链接 · Lukas Guldstøv · CC BY-SA 4.0

I'm having some trouble configuring client authentication using saslauthd and postfix on ubuntu 22.04. The issue is that users are not getting authenticated although the user exists. It's my first time setting up postfix and saslauthd so it might be obvious to some of you serverfault sharks.

The email sending works fine using mail command. Using telnet everything looks okay but with remote SMTP client with auth it doesn't work. I'm 6 hours deep and close to quitting (for today).

Doing a telnet from a remote server:

telnet mail.mydomain.com 25
Trying IP...
Connected to mail.mydomain.com.
Escape character is '^]'.
220 mail.mydomain.com ESMTP Postfix (Ubuntu)
EHLO mydomain.com
250-mail.mydomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH SCRAM-SHA-1 SCRAM-SHA-256 DIGEST-MD5 NTLM CRAM-MD5 PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING
421 4.4.2 mail.mydomain.com Error: timeout exceeded
Connection closed by foreign host.

Verifying that the user i created actually exists

testsaslauthd -u lukas -p mypassword -r mydomain.com
0: OK "Success."

/var/log/mail.log (please notice that verification FAILS here even though it has just been successfully tested above.

Mar  9 04:36:42 postfix/smtpd[42026]: warning: SASL authentication failure: Password verification failed
Mar  9 04:36:42 postfix/smtpd[42026]: warning: IPbredband.3.dk[IP]: SASL PLAIN authentication failed: authentication failure
Mar  9 04:36:42 postfix/smtpd[42026]: lost connection after AUTH from IP.bredband.3.dk[IP]
Mar  9 04:36:42 postfix/smtpd[42026]: disconnect from IP.bredband.3.dk[IP] ehlo=2 starttls=1 auth=0/1 commands=3/4

Where I’m currently trying to login via nodemailer’s SMTP module (this shouldn't be the issue - but better safe than sorry):

import nodemailer from "nodemailer"

const transporter = nodemailer.createTransport({
  host: "mail.mydomain.com",
  port: 25,
  secure: false, // Use `true` for port 465, `false` for all other ports
  auth: {
    user: "[email omitted]”,
    pass: “myapassword
  },
});

 
router.post('/', async (req, res) => {

  const info = await transporter.sendMail({
    from: '"Maddison Foo Koch " <username@mydomain>', // sender address
    to: "[email omitted]”, // list of receivers
    subject: "Hello!", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>", // html body
  });

  console.log("Message sent: %s", info.messageId);
  return res.status(200).json({ data:"ok", info: JSON.stringify(info) });
  });

/etc/postfix/master.cf (chroot enabled)

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd

/etc/postfix/main.cf (highly believe something is wrong in this file)

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no 
compatibility_level = 3.6



# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/mail.mydomain.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mail.mydomain.com/privkey.pem
smtpd_tls_security_level=may

smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


# auth
#smtpd_sasl_path = smtpd
smtpd_sasl_type = cyrus
smtpd_sasl_path = var/run/saslauthd/mux
#smtpd_sasl_path = var/run/saslauthd/saslauthd/mux
#smtpd_sasl_path = /var/spool/postfix/var/run/saslauthd/saslauthd

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mydomain.com, localhost.com, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

/etc/postfix/sasl/smtpd.conf

pwcheck_method: saslauthd
mech_list: plain login 

/etc/default/saslauthd

START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="sasldb"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/run/saslauthd"

Furthermore, there is a symlink between /var/run/saslauthd and /var/spool/postfix/var/run/saslauthd

Any hints or help is much appreciated!

已采纳解答

原帖链接 · Lukas Guldstøv · CC BY-SA 4.0

The solution was to add modify the following file /etc/default/saslauthd

    START=yes 
    
      
    DESC="SASL Authentication Daemon" 
    
    NAME="saslauthd" 
    
    MECHANISMS="sasldb"
    MECH_OPTIONS="" 
    
     
     
    
    THREADS=5 
    # modified to look in the chrooted folder which has a symlink to var/run/saslauthd and can be run by postfix
    OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd" 

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2024-03-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。