CentOS 6, CentOS 7のDovecot(バージョン2)でPostfixのバーチャルメールボックスにアクセスできるようにする - Dovecot

CentOS6でPostfixのバーチャルメールボックスにアクセスできるようにDovecotを設定します。

/etc/dovecot/conf.d/10-auth.conf の編集

/etc/dovecot/conf.d/10-auth.conf ファイルを編集します。
10-auth.confファイルの下部の
#!include auth-deny.conf.ext
#!include auth-master.conf.ext

!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext
とincludeが並んでいる部分を
#!include auth-deny.conf.ext
#!include auth-master.conf.ext

!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext
とします。(!include auth-passwdfile.conf.extを有効にします。)

Plaintextでの認証の有効化

Version2のDovecotでは、デフォルトでPaintTextの認証が無効になっています。/etc/dovecot/conf.d/10-auth.confファイルの
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
#disable_plaintext_auth = yes
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
#disable_plaintext_auth = yes
disable_plaintext_auth = no
とします。

SSL強制の無効化

当初のDovcot2 では設定の必要がありませんでしたが、新しいバージョンのDovecot2 では、SSL強制設定が有効になっているため、無効化する必要があります。この設定をしないと、10-auth.conf で設定した disable_plaintext_auth = no の設定が有効になりません。詳細についてはこちらの記事も参照してください。

/etc/dovecot/conf.d/10-ssl.conf ファイルを編集します。
編集前
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
# disable plain pop3 and imap, allowed are only pop3+TLS, pop3s, imap+TLS and imaps
# plain imap and pop3 are still allowed for local connections
ssl = required
編集後
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
# disable plain pop3 and imap, allowed are only pop3+TLS, pop3s, imap+TLS and imaps
# plain imap and pop3 are still allowed for local connections
ssl = yes
"ssl = required" を "ssl = yes" に変更します。この設定によりsslが必須でなくなります。

pam認証を無効にする

pam認証を使っていない場合は無効化しておいたほうが良い場合があります。詳しくはこちらの記事を参照してください。
pam認証を無効化する場合は、10-auth.confファイルの下部の
#!include auth-deny.conf.ext
#!include auth-master.conf.ext

!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext
#!include auth-deny.conf.ext
#!include auth-master.conf.ext

#!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext
とします。(!include auth-system.conf.extをコメントアウトします。)

/etc/dovecot/conf.d/auth-passwdfile.conf.ext の編集

passdbの設定

/etc/dovecot/conf.d/auth-passwdfile.conf.ext ファイルを編集します。
# Authentication for passwd-file users. Included from auth.conf.
#
# passwd-like file with specified location.
# <doc/wiki/AuthDatabase.PasswdFile.txt>

passdb {
  driver = passwd-file
  args = scheme=CRYPT username_format=%u /etc/dovecot/users
}

userdb {
  driver = passwd-file
  args = username_format=%u /etc/dovecot/users
}
となっているのを
# Authentication for passwd-file users. Included from auth.conf.
#
# passwd-like file with specified location.
# <doc/wiki/AuthDatabase.PasswdFile.txt>

passdb {
  driver = passwd-file
#  args = scheme=CRYPT username_format=%u /etc/dovecot/users
  args = /etc/dovecot/passwd
}

userdb {
  driver = passwd-file
#  args = username_format=%u /etc/dovecot/users
  args = /etc/dovecot/passwd
}
と変更します。

パスワードの作成 (passwd-file ファイルの作成)

/etc/dovecot/passwd ファイルを作成します。
ファイルには
(ユーザー名):{HMAC-MD5}abcdefg123456....:(uid):(gid):::::(メールボックスへのパス)
...
を記述します。{HMAC-MD5}...の部分は以下の手順で作成します。

CentOS 7 の場合

CentOS 7ではdovecotpwコマンドがなくなったため、doveadm コマンドを利用します。
doveadm pw -s HMAC-MD5
コマンドを入力します。
パスワード入力プロンプトが表示されますので、パスワードを入力すると、HMAC-MD5のハッシュ値が出力されます。

CentOS 6 の場合

下記のdovecotpwコマンドで取得したハッシュ値を入れます。
dovecotpw
コマンドを用いてパスワードのハッシュ値を取得します。
>dovecotpw
Enter new password:
Retype new password:
{HMAC-MD5}abcdefg123456789.....


今回は以下の記述をしました。
 
 test@ipentec.com:{HMAC-MD5}78ed1abd527d1aa3921f58bfe651b178d23aff2d88ed7b567e30069ad6ae45c6:5000:5000:::::Maildir:/home/vmail/vhosts/ipentec.com/test/Maildir
 info@ipentec.com:{HMAC-MD5}78ed1abd527d1aa3921f58bfe651b178d23aff2d88ed7b567e30069ad6ae45c6:5000:5000:::::Maildir:/home/vmail/vhosts/ipentec.com/info/Maildir
 penguin@ipentec.com:{HMAC-MD5}78ed1abd527d1aa3921f58bfe651b178d23aff2d88ed7b567e30069ad6ae45c6:5000:5000:::::Maildir:/home/vmail/vhosts/ipentec.com/penguin/Maildir
 info@ixx.jp:{HMAC-MD5}78ed1abd527d1aa3921f58bfe651b178d23aff2d88ed7b567e30069ad6ae45c6:5000:5000:::::Maildir:/home/vmail/vhosts/ixx.jp/info/Maildir
Maildir形式を採用するためメールボックスのパスの前にMaildir:を追記します。メールボックスのパスはPostfixの設定時にvirtual_mailbox_baseに設定したパスとvmailboxに記載したディレクトリがメールボックスのパスになります。
ディレクトリパスはメールディレクトリ名の"Maildir"まで必要です。
詳しくはこちらの記事を参照してください。

dovecot の起動

dovecot を起動します。
CentOS7 の場合
systemctl start dovecot
または
systemctl restart dovecot
コマンドを実行します。
CentOS6 の場合
/etc/rc.d/init.d dovecot start
または
/etc/rc.d/init.d dovecot restart
コマンドを実行します。
著者
かつて日本を代表したスーパーエンジニア (自称)
ハードウェア、電気設備、ガーデニング関係の記事を担当。
最終更新日: 2024-01-06
作成日: 2011-09-23
iPentec all rights reserverd.