Difference between revisions of "Dovecot"
From wiki
(Created page with "{{WIP}} == Install == <syntaxhighlight lang="console"> # apt install dovecot-imapd dovecot-managesieved </syntaxhighlight> Category:Linux Server") |
(Configure authentication) |
||
Line 5: | Line 5: | ||
# apt install dovecot-imapd dovecot-managesieved | # apt install dovecot-imapd dovecot-managesieved | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | == Configuration == | ||
+ | |||
+ | === Create System User === | ||
+ | |||
+ | User vmail will be used to store mail related data | ||
+ | <syntaxhighlight lang="console"> | ||
+ | # adduser --system --home /var/maildir/ --group vmail | ||
+ | Adding system user `vmail' (UID 104) ... | ||
+ | Adding new group `vmail' (GID 105) ... | ||
+ | Adding new user `vmail' (UID 104) with group `vmail' ... | ||
+ | Creating home directory `/var/maildir/' ... | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Authentication === | ||
+ | |||
+ | ==== Activate ==== | ||
+ | |||
+ | Edit file <code>/etc/dovecot/conf.d/10-auth.conf</code> and make sure the '''only''' included authentication mechanism is passwdfile. | ||
+ | <syntaxhighlight lang="sh"> | ||
+ | #!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 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | Edit file <code>/etc/dovecot/conf.d/auth-passwdfile.conf.ext</code> and set option <code>default_fields</code> | ||
+ | <syntaxhighlight lang="sh"> | ||
+ | # Authentication for passwd-file users. Included from 10-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 | ||
+ | |||
+ | # Default fields that can be overridden by passwd-file | ||
+ | #default_fields = quota_rule=*:storage=1G | ||
+ | default_fields = uid=vmail gid=vmail home=/home/vmail/%u | ||
+ | |||
+ | # Override fields from passwd-file | ||
+ | #override_fields = home=/home/virtual/%u | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | Create file <code>/etc/dovecot/users</code> | ||
+ | <syntaxhighlight lang="console"> | ||
+ | # touch /etc/dovecot/users | ||
+ | # chmod 640 /etc/dovecot/users | ||
+ | # chown root:dovecot /etc/dovecot/users | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== Add a User ==== | ||
+ | |||
+ | First generate an encrypted password for the user | ||
+ | <syntaxhighlight lang="console"> | ||
+ | $ doveadm pw -s SHA512-CRYPT | ||
+ | Enter new password: | ||
+ | Retype new password: | ||
+ | {SHA512-CRYPT}$6$o5TBpwJqGhEgsq3G$YGUPIDDkAJGaRYdMrW4kNWQzEyCwyeJAxnnyyphcR8MjPUo4yzUNy55sgAP0Qx73CI72XzUqIFGlKUvir7QkR1 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Now add a line to <code>/etc/dovecot/users</code> | ||
+ | <syntaxhighlight lang="shell"> | ||
+ | # Format is <user>:<password>:::::: | ||
+ | # Generate passwords with: doveadm pw -s SHA512-CRYPT | ||
+ | vincent:{SHA512-CRYPT}$6$o5TBpwJqGhEgsq3G$YGUPIDDkAJGaRYdMrW4kNWQzEyCwyeJAxnnyyphcR8MjPUo4yzUNy55sgAP0Qx73CI72XzUqIFGlKUvir7QkR1:::::: | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
[[Category:Linux Server]] | [[Category:Linux Server]] |
Revision as of 23:16, 16 March 2016
Warning: | This page is a work in progress and is not completed. Important informations might be missing or wrong. |
Install
# apt install dovecot-imapd dovecot-managesieved
Configuration
Create System User
User vmail will be used to store mail related data
# adduser --system --home /var/maildir/ --group vmail
Adding system user `vmail' (UID 104) ...
Adding new group `vmail' (GID 105) ...
Adding new user `vmail' (UID 104) with group `vmail' ...
Creating home directory `/var/maildir/' ...
Authentication
Activate
Edit file /etc/dovecot/conf.d/10-auth.conf
and make sure the only included authentication mechanism is passwdfile.
#!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
Edit file /etc/dovecot/conf.d/auth-passwdfile.conf.ext
and set option default_fields
# Authentication for passwd-file users. Included from 10-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
# Default fields that can be overridden by passwd-file
#default_fields = quota_rule=*:storage=1G
default_fields = uid=vmail gid=vmail home=/home/vmail/%u
# Override fields from passwd-file
#override_fields = home=/home/virtual/%u
}
Create file /etc/dovecot/users
# touch /etc/dovecot/users
# chmod 640 /etc/dovecot/users
# chown root:dovecot /etc/dovecot/users
Add a User
First generate an encrypted password for the user
$ doveadm pw -s SHA512-CRYPT
Enter new password:
Retype new password:
{SHA512-CRYPT}$6$o5TBpwJqGhEgsq3G$YGUPIDDkAJGaRYdMrW4kNWQzEyCwyeJAxnnyyphcR8MjPUo4yzUNy55sgAP0Qx73CI72XzUqIFGlKUvir7QkR1
Now add a line to /etc/dovecot/users
# Format is <user>:<password>::::::
# Generate passwords with: doveadm pw -s SHA512-CRYPT
vincent:{SHA512-CRYPT}$6$o5TBpwJqGhEgsq3G$YGUPIDDkAJGaRYdMrW4kNWQzEyCwyeJAxnnyyphcR8MjPUo4yzUNy55sgAP0Qx73CI72XzUqIFGlKUvir7QkR1::::::