「Postfix と SASL」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(ページの作成:「Category:メールサーバー en:PostFix Howto With SASL {{Related articles start}} {{Related|Postfix}} {{Related|Dovecot}} {{Related articles end}} [http://www....」)
 
(同期)
1行目: 1行目:
 
[[Category:メールサーバー]]
 
[[Category:メールサーバー]]
[[en:PostFix Howto With SASL]]
+
[[en:Postfix with SASL]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Postfix}}
 
{{Related|Postfix}}
83行目: 83行目:
 
{{bc|<nowiki>
 
{{bc|<nowiki>
 
# SASL authentication with dovecot
 
# SASL authentication with dovecot
  +
-o smtpd_tls_security_level=encrypt
 
-o smtpd_sasl_auth_enable=yes
 
-o smtpd_sasl_auth_enable=yes
 
-o smtpd_sasl_type=dovecot
 
-o smtpd_sasl_type=dovecot
113行目: 114行目:
 
== 参照 ==
 
== 参照 ==
   
* [http://www.postfix.org/SASL_README.html Postfix SASL readme] in Postfix official documentation.
+
* Postfix 公式ドキュメントの [http://www.postfix.org/SASL_README.html Postfix SASL readme]
* [http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL SASL authentication with Dovecot] in Dovecot official documentation.
+
* Dovecot 公式ドキュメントの [http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL SASL authentication with Dovecot]
 
* [http://wiki.centos.org/HowTos/postfix_sasl Centos Howto Postfix SASL]
 
* [http://wiki.centos.org/HowTos/postfix_sasl Centos Howto Postfix SASL]

2017年6月12日 (月) 22:03時点における版

関連記事

Postfix のサイト より:

わざわざ Postfix をインストールする人たちは、Postfix が他のメーラよりもセキュアであると思っていることでしょう。Cyrus SASL ライブラリは大量のコードで成り立っています。Postfix SMTP クライアントや SMTP サーバで SASL 認証を有効にしても、 Postfix は Cyrus SASL ライブラリを使う他のメールシステムと同程度にしかセキュアになりません。Dovecot は検討に値するかもしれない代替策を提供しています。

イントロダクション

この記事では Postfix で SASL 認証をセットアップする方法を説明します。

Postfix を立ち上げたら SASL 認証を追加することでリレーをなくすことができます。認証を通過した信頼できるユーザーだけがメールを送ることができるようになります。匿名ユーザーによってスパムが作成されるのを防げます。

[extra]] に入っている postfix パッケージは既に SASL のサポートを有効にしてコンパイルされているので、SASL 認証を使う場合、2つの選択肢があります:

  • cyrus-sasl パッケージを使う。
  • Dovecot を有効にして (Dovecot の認証だけでなく) Postfix の認証を処理させる。

cyrus-sasl パッケージの設定

公式リポジトリから cyrus-saslインストールしてください。

SASL を有効にして他のユーザーからのメールを承認するには、/etc/postfix/master.cf で (デフォルトで存在するがコメントアウトされている) 以下の行をアンコメントして "Message submission" ポート (TCP 587) を開きます:

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_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

上記の設定では SSL も有効になるので、SSL 証明書を持っていない場合は、"smtpd_tls_security_level" オプションはコメントアウトされたままにしてください。

3つの制限オプション (client, helo, sender) もコメントアウトしたままにできます。smtpd_recipient_restrictions は既に SASL ユーザーを処理するからです。

通常通りに Postfix をセットアップして起動します。ブート時に起動するようにしたいときは有効化してください。

SASL は複数の認証方式を使うことができます。デフォルトの認証方式は PAM (/etc/conf.d/saslauthd で設定) ですが、正しくセットアップするには /usr/lib/sasl2/smtpd.conf を作成する必要があります:

pwcheck_method: saslauthd
mech_list: plain
log_level: 7

postfix と saslauthd サービスを再起動してください。

上手く行っていれば、次のコマンドで Postfix サーバーに telnet できるはずです: telnet localhost 587

それから、次のコマンドを入力してください: EHLO test.com

以下のように表示されるはずです:

Trying 127.0.0.1...

Connected to localhost.localdomain
Escape character is '^]'

220 justin ESMTP Postfix
EHLO test.com
250-justin
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN OTP DIGEST-MD5 CRAM-MD5
250 8BITMIME

Dovecot の設定

IMAP や POP メールサーバーとして Dovecot を使っていて既に (PAM などで) 認証を設定している場合、他のパッケージを設定する必要はありません。

/etc/postfix/master.cf を編集して submission または smtp セクションの下に以下の行を追加してください:

  # SASL authentication with dovecot
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_sasl_security_options=noanonymous
  -o smtpd_sasl_local_domain=$myhostname
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_recipient_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject

上記の設定で、認証を受けたユーザーだけがメールを送信できるようになります。smtpd_client_restrictions がそれです。

以下を Dovecot 設定ファイル /etc/dovecot/dovecot.conf に追加してください:

service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  user = root
}

master.cfsmtpd_sasl_path オプションで指定したのと同じ /var/spool/postfix/private/auth に unix ソケットが作成されます。

最後に postfix と dovecot サービスを再起動してください。

参照