質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
SASL

SASLは、コネクションベースのプロトコルにおける認証サポートの追加や、データセキュリティのためのフレームワーク。既存のライブラリ・仕組みを再利用することが可能で,ユーザーに対しチャレンジ・レスポンス認証といった安全な認証方式を提供できます。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SMTP

SMTP(Simple Mail Transfer Protocol)はIPネットワークでemailを伝送する為のプロトコルです。

Postfix

Postfixは、電子メールサーバソフトウェアで、 メールを配送するシステムMTAの一種です。

Q&A

解決済

1回答

10722閲覧

CentOSでのpostfixのSMTP認証(sasl)でエラー

lonoru

総合スコア18

SASL

SASLは、コネクションベースのプロトコルにおける認証サポートの追加や、データセキュリティのためのフレームワーク。既存のライブラリ・仕組みを再利用することが可能で,ユーザーに対しチャレンジ・レスポンス認証といった安全な認証方式を提供できます。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SMTP

SMTP(Simple Mail Transfer Protocol)はIPネットワークでemailを伝送する為のプロトコルです。

Postfix

Postfixは、電子メールサーバソフトウェアで、 メールを配送するシステムMTAの一種です。

0グッド

1クリップ

投稿2019/09/05 09:58

社内のPCからメールを送信するためのsmtpサーバを立てるため
クラウド上(AWS)のサーバ(CentOS)にpostfixとsmtp認証のためのsaslをインストールし、ひと通り設定しました。
動作確認でtestsaslauthdコマンドを叩いたところ、 0: NO "authentication failed"が返ってきてしまいます。
設定を何度も見直し、参考サイトをいくつも見て比較し、確認したのですが差があるようにみえず、どこに問題あるのか未だ解決できていません。

設定内容からここがおかしい、足りないなどがあれば教えていただけますと助かります。
以下、各種設定した内容になります。不足情報がありましたら追記します。
よろしくお願いします。

# testsaslauthd -u xxxx -p passwd -r hogehoge.co.jp -s smtp 0: NO "authentication failed"
# cat /var/log/messages (抜粋) saslauthd[20334]: do_auth : auth failure: [user=xxxx] [service=smtp] [realm=hogehoge.co.jp] [mech=pam] [reason=PAM auth error]
# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
# rpm -qa cyrus-sasl* cyrus-sasl-2.1.26-23.el7.x86_64 cyrus-sasl-md5-2.1.26-23.el7.x86_64 cyrus-sasl-lib-2.1.26-23.el7.x86_64 cyrus-sasl-gssapi-2.1.26-23.el7.x86_64 cyrus-sasl-scram-2.1.26-23.el7.x86_64 cyrus-sasl-plain-2.1.26-23.el7.x86_64 cyrus-sasl-devel-2.1.26-23.el7.x86_64
# sasldblistusers2 xxxx@hogehoge.co.jp: userPassword
# ll /etc/sasldb2 -rw-r----- 1 postfix postfix 12288 Sep 4 17:40 /etc/sasldb2
# cat /etc/sasl2/smtpd.conf #pwcheck_method: saslauthd pwcheck_method: auxprop #mech_list: plain login mech_list: cram-md5 digest-md5 plain login auxprop_plugin: sasldb
# cat /etc/sasl2/Sendmail.conf pwcheck_method:saslauthd
# cat /etc/sysconfig/saslauthd # Directory in which to place saslauthd's listening socket, pid file, and so # on. This directory must already exist. SOCKETDIR=/run/saslauthd # Mechanism to use when checking passwords. Run "saslauthd -v" to get a list # of which mechanism your installation was compiled with the ablity to use. MECH=pam # Additional flags to pass to saslauthd on the command line. See saslauthd(8) # for the list of accepted flags. FLAGS=
# cat /etc/pam.d/smtp #%PAM-1.0 auth include password-auth account include password-auth
# postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases broken_sasl_auth_clients = yes command_directory = /usr/sbin config_directory = /etc/postfix cyrus_sasl_config_path = /etc/sasl2/ daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 disable_vrfy_command = yes home_mailbox = Maildir/ html_directory = no inet_interfaces = all inet_protocols = ipv4 mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man message_size_limit = 25600000 milter_default_action = accept mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mydomain = hogehoge.co.jp myhostname = hogehoge.co.jp mynetworks = 127.0.0.0/8 myorigin = $mydomain newaliases_path = /usr/bin/newaliases.postfix non_smtpd_milters = $smtpd_milters queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES relay_domains = $mydestination sample_directory = /usr/share/doc/postfix-2.10.1/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop smtp_tls_CAfile = /etc/pki/tls/cert.pem smtp_tls_loglevel = 1 smtp_tls_security_level = may smtpd_banner = $myhostname ESMTP unknown smtpd_helo_required = yes smtpd_milters = inet:127.0.0.1:8891 smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous unknown_local_recipient_reject_code = 550
# cat /etc/postfix/master.cf (抜粋) smtp inet n - n - - smtpd #smtp inet n - n - 1 postscreen #smtpd pass - - n - - smtpd #dnsblog unix - - n - 0 dnsblog #tlsproxy unix - - n - 0 tlsproxy submission inet n - n - - smtpd # -o syslog_name=postfix/submission # -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes # -o smtpd_reject_unlisted_recipient=no # -o smtpd_client_restrictions=$mua_client_restrictions -o smtpd_client_restrictions=permit_sasl_authenticated,reject
# postconf | grep mail_version mail_version = 2.10.1
# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

scsi

2019/09/05 15:36 編集

念の為ですが saslauthd は起動してますか? 確認したユーザは OS の user としても存在しますか?
lonoru

2019/09/06 05:01

はい、saslauthdは起動しています。 # ps -ef | grep saslauthd root 20332 1 0 Sep05 ? 00:00:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam 確認したユーザはxxxxというユーザ自体は存在しますが saslpasswd2 -c -u hogehoge.co.jp xxxx で作ったものでパスワードは異なります。
guest

回答1

0

ベストアンサー

saslauthd は PAM で認証するよう設定・起動していますので、/etc/sasldb2 は参照せず、デフォルトでは /etc/passwd, /etc/shadow で認証します。
したがって、/etc/sasldb2 に登録したユーザー/パスワードは testsaslauthd ではテストすることができません。

一方、/etc/sasl2/smtpd.conf で pwcheck_method: saslauthd ではなく、pwcheck_method: auxprop としているので、postfix は libsasl2 経由で /etc/sasldb2 を直接参照します。
この場合、saslauthd は使いませんので、起動する必要もありません。
テストは、TCP 25番ポートや、587番ポート(STARTTLS) に接続して確認ください。

投稿2019/09/05 14:55

TaichiYanagiya

総合スコア12146

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

scsi

2019/09/05 15:40

saslauthd は ldap の認証以外使用したことがなかったのでとても勉強になりました!
lonoru

2019/09/06 05:06 編集

ご回答ありがとうございます。 ということは設定自体は問題ない、という認識で正しいでしょうか? 手元にメーラーで直接接続確認できるメアドがなかったため、 取り急ぎtelnet(25, 587)で接続確認してみたのですが、以下のエラーが発生しました。 こちらの原因としては何が考えられるでしょうか?追加で教えていただけますと助かります。 ``` $ telnet xxx.xxx.xxx.xxx 587 Trying xxx.xxx.xxx.xxx... Connected to hogehoge.co.jp. Escape character is '^]'. 220 hogehoge.co.jp ESMTP unknown EHLO hogehoge.co.jp 250-hogehoge.co.jp 250-PIPELINING 250-SIZE 25600000 250-ETRN 250-AUTH CRAM-MD5 DIGEST-MD5 PLAIN LOGIN 250-AUTH=CRAM-MD5 DIGEST-MD5 PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN AUTH PLAIN eHh4eEBob2dlaG9nZS5jby5qcAB4eHh4QGhvZ2Vob2dlLmNvLmpwAHBhc3N3ZA== 535 5.7.8 Error: authentication failed: bad protocol / cancel ``` AUTH PLAINでセットした値は以下で取得しました。 ``` $ echo -en "xxxx@hogehoge.co.jp\0xxxx@hogehoge.co.jp\0passwd" | base64 eHh4eEBob2dlaG9nZS5jby5qcAB4eHh4QGhvZ2Vob2dlLmNvLmpwAHBhc3N3ZA== ```
TaichiYanagiya

2019/09/06 07:06

テスト手順は間違っていないと思います。 "bad protocol" は Base64 文字列が復号できない場合にも該当しますが、何ででしょうね。 "journalctl -u postfix.service" または /var/log/maillog には何かエラーの原因が記録されていないでしょうか?
lonoru

2019/09/06 08:05

ありがとうございます。 ログには以下の出力がありました。 warning: SASL authentication failure: Can only find author/en (no password) warning: SASL PLAIN authentication failed: bad protocol / cancel これを元に調べていましたら、SASL認証用ユーザのパスワードが数字で始まると同様のエラーになるという記事を見つけまして、試しにユーザを作り直したところ、 235 2.7.0 Authentication successful と成功しました! あとは実際に繋いで確認してみて結果をご報告します。
lonoru

2019/09/09 07:57

その後、macのthunderbirdよりgmailアカウントを設定して今回構築したsmtpサーバを指定したところ、無事メール送信できることを確認しました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問