Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
lpi2:dovecot-virtual-domains [2022/12/18 07:40] ingo_wichmann [Dovecot: virtuelle Domains und Benutzer in Textdateien] |
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]] | ||
Benutzer vmail und Mailverzeichnis anlegen: | Benutzer vmail und Mailverzeichnis anlegen: | ||
- | mkdir -p /srv/vmail/example.com/home | + | mkdir -p /srv/vmail/example.com |
useradd -r -U -s /bin/false -d /srv/vmail vmail | useradd -r -U -s /bin/false -d /srv/vmail vmail | ||
- | chown -R vmail:vmail /srv/vmail/example.com | + | chown vmail:vmail /srv/vmail/example.com |
Dovecot konfigurieren: | Dovecot konfigurieren: | ||
- | ''/etc/dovecot/dovecot.conf'' : | + | <file txt /etc/dovecot/local.conf> |
- | + | mail_location = maildir:~/Maildir | |
- | <file> | + | |
- | mail_location = maildir:/srv/vmail/%d/home/%n/Maildir | + | |
auth_username_format = %Lu | 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/home/%n | + | 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 | ||
- | Beispiel-Benutzer anlegen: ((https://doc.dovecot.org/configuration_manual/authentication/password_schemes/#authentication-password-schemes)) | + | Benutzer anlegen: ((https://doc.dovecot.org/configuration_manual/authentication/password_schemes/#authentication-password-schemes)) |
doveadm pw -l | doveadm pw -l | ||
- | doveadm pw -s BLF-CRYPT | + | doveadm pw -s BLF-CRYPT | tee -a /srv/vmail/passwd |
- | ''/srv/vmail/example.com/passwd'' : | + | <file txt /srv/vmail/passwd> |
- | <file> | + | user1@example.com:{BLF-CRYPT}$2y$05$XF8X/y47o1sfXTiwX5JkzOn0uGvZw9QCtHOKRinCsMc.rtAElVHOG:: |
- | user1:{BLF-CRYPT}$2y$05$XF8X/y47o1sfXTiwX5JkzOn0uGvZw9QCtHOKRinCsMc.rtAElVHOG | + | user2@example.com:{SSHA256}NZMbbjQl2IsI8Qurnfgl2XjTxD/8eNf4IYD+AdiikArZ+WZI:: |
- | user2:{SSHA256}NZMbbjQl2IsI8Qurnfgl2XjTxD/8eNf4IYD+AdiikArZ+WZI | + | |
</file> | </file> | ||
====== Testen ====== | ====== Testen ====== | ||
- | netcat -v localhost 143 | + | 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 | . login user1@example.com xxx | ||
+ | |||