Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Nächste Überarbeitung | Vorherige Überarbeitung | ||
lpi2:dovecot-virtual-domains [2014/02/26 23:12] ingo_wichmann angelegt |
lpi2:dovecot-virtual-domains [2024/08/10 10:22] (aktuell) ingo_wichmann [Testen] |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Dovecot: virtuelle Domains und Benutzer in Textdateien ====== | ====== Dovecot: virtuelle Domains und Benutzer in Textdateien ====== | ||
- | //in der Praxis würde ich LDAP oder eine Datenbank bevorzugen// | + | |
+ | Dokumentation: https://doc.dovecot.org/configuration_manual/virtual_users/ | ||
Voraussetzung: [[dovecot-imapd]] | Voraussetzung: [[dovecot-imapd]] | ||
- | ''/etc/dovecot/dovecot.conf'' : | + | Benutzer vmail und Mailverzeichnis anlegen: |
+ | mkdir -p /srv/vmail/example.com | ||
+ | useradd -r -U -s /bin/false -d /srv/vmail vmail | ||
+ | chown vmail:vmail /srv/vmail/example.com | ||
- | <file> | + | Dovecot konfigurieren: |
- | mail_location = maildir:/srv/vmail/%d/maildir/%n | + | |
+ | <file txt /etc/dovecot/local.conf> | ||
+ | mail_location = maildir:~/Maildir | ||
+ | auth_username_format = %Lu | ||
userdb { | userdb { | ||
- | args = username_format=%n /srv/vmail/%d/passwd | + | args = /srv/vmail/passwd |
+ | default_fields = uid=vmail gid=vmail home=/srv/vmail/%d/%n | ||
driver = passwd-file | driver = passwd-file | ||
} | } | ||
passdb { | passdb { | ||
- | args = username_format=%n /srv/vmail/%d/passwd | + | args = /srv/vmail/passwd |
driver = passwd-file | driver = passwd-file | ||
} | } | ||
</file> | </file> | ||
+ | doveconf auth_username_format | ||
+ | -> ''auth_username_format = **%Lu**'' | ||
+ | doveconf -n | grep -EA4 '^(userdb|passdb)' | ||
+ | systemctl reload dovecot.service | ||
+ | |||
+ | Benutzer anlegen: ((https://doc.dovecot.org/configuration_manual/authentication/password_schemes/#authentication-password-schemes)) | ||
+ | doveadm pw -l | ||
+ | doveadm pw -s BLF-CRYPT | tee -a /srv/vmail/passwd | ||
+ | |||
+ | <file txt /srv/vmail/passwd> | ||
+ | user1@example.com:{BLF-CRYPT}$2y$05$XF8X/y47o1sfXTiwX5JkzOn0uGvZw9QCtHOKRinCsMc.rtAElVHOG:: | ||
+ | user2@example.com:{SSHA256}NZMbbjQl2IsI8Qurnfgl2XjTxD/8eNf4IYD+AdiikArZ+WZI:: | ||
+ | </file> | ||
+ | |||
+ | ====== Testen ====== | ||
+ | Kennt dovecot die Benutzer? | ||
+ | doveadm user '*' | ||
+ | doveadm user user1@example.com | ||
+ | -> ''home /srv/vmail/example.com/user1'' | ||
+ | |||
+ | Funktioniert die Authentifizierung? | ||
+ | doveadm auth test user1@example.com | ||
+ | -> ''auth succeeded'' | ||
+ | |||
+ | Mit curl: | ||
+ | curl -v --url imap://localhost:143 --user me@klaus-1.lxht.de | ||
+ | -> ''OK Logged in'' | ||
+ | |||
+ | Mit curl + TLS: | ||
+ | curl -v --ssl-reqd --url imaps://example.com:993 --user user1@example.com | ||
+ | |||
+ | Kann man sich lokal anmelden (mit TLS): | ||
+ | openssl s_client -crlf -connect localhost:993 | ||
+ | . login user1@example.com xxx | ||
- | mkdir -p /srv/vmail/example.com/{passwd,maildir} | ||