Diese Anleitung beschreibt, wie Sie virtuelles E-Mail-Hosting mit einem LDAP-Back-End einrichten und konfigurieren.
Die Software, die wir in diesem Howto verwenden werden: Postfix (MTA), Dovecot (IMAP / POP3), Gnarwl (Urlaub), OpenLDAP (LDAP) und vMailpanel als Verwaltungsschnittstelle.
Optional sind Proftpd FTP, Roundcube (Webmail) und MariaDB (SQL-Backend für Roundcube).
Das hat bei mir funktioniert, aber ich kann nicht garantieren, dass diese Einrichtung bei Ihnen funktioniert, daher kommt diese Anleitung ohne jegliche Garantie.
Annahmen
Diese Anleitung geht von folgenden Konfigurationen aus, wenn Ihre Installation davon abweicht, dann ersetzen Sie die Einträge unten durch Ihre tatsächliche Konfiguration.
E-Mail-Zustellpfad (Postfächer):
/home/vmail/
Benutzer-vmail:
UID:1000, GID:1000
Nutzer-Postfix:
UID: 108, GID:108
OpenLDAP-Basis-DN:
dc=example,dc=tld
OpenLDAP-Administratorkonto:
cn=admin,dc=example,dc=tld
vMailpanel-Such-DN:
o=hosting,dc=example,dc=tld
Ein schreibgeschütztes Konto für den Baum o=hosting,dc=example,dc=tld:
cn=vmail,o=hosting,dc=example,dc=tld
In diesem Handbuch verwenden Sie root als Benutzer.
Wenn Sie beispielsweise o=maildomains oder ou=domains möchten, achten Sie bitte darauf, o=hosting durch das zu ersetzen, was Sie möchten, insbesondere in der acl.ldif. Diese ACL-Datei ist streng, phamm wird nicht richtig funktionieren, wenn sie nicht genau so ist, wie sie sein sollte. Wenn Sie einen anderen Nur-Lese-Benutzer als phamm wollen, dann ersetzen Sie cn=phamm überall in dieser Anleitung durch cn=wat-you.
Diese Anleitung geht auch davon aus, dass Sie Ihren Ubuntu-Server gemäß Ihren Anforderungen installiert und konfiguriert haben, es gibt viele gute Anleitungen auf Howtoforge, zum Beispiel:
Der perfekte Server – Ubuntu 18.04 (Bionic Beaver) mit Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot und ISPConfig 3.1
Sie können nach der Installation und Konfiguration von Apache2 aufhören.
Schritt 1:Laden Sie vMailpanel herunter
Laden Sie das vMailpanel-Paket herunter:
cd /usr/share
Holen Sie sich die neueste Version von vMailpanel:
git clone https://git.com/wolmfan68/vMailpanel
OK, jetzt können wir anfangen.
Schritt 2:OpenLDAP installieren und konfigurieren
Installieren Sie OpenLDAP und ldap-utils:
apt -y install slapd ldap-utils php-ldap
Konfigurieren Sie slapd neu, um sicherzustellen, dass es Ihrem gewünschten Setup entspricht
dpkg-reconfigure slapd
Sie müssen einige Fragen beantworten:
Omit OpenLDAP server configuration? No
DNS domain name: example.tld ==>put your domain name here
Organization name: example.tld ==> put your organization here
Administrator password: secret ==> put your password
Confirm password: secret
Database backend to use: MDB
Do you want the database to be removed when slapd is purged? Yes
Move old database? Yes
Wechseln Sie in das Verzeichnis /etc/ldap/schema:
cd /etc/ldap/schema
Kopieren Sie phamm.schema und perversia.net.schema aus dem phamm-Paket in das Schemaverzeichnis:
cp /usr/share/vMailbox/schema/* /etc/ldap/schema.
Jetzt fügen wir die Schemas zu openldap hinzu.
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/phamm.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/ISPEnv2.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/amavis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/pureftpd.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/perversia.net.ldif
Jetzt erstellen wir den Eintrag o=hosting und das vmail-Konto.
Passen Sie den Text unten an Ihre Bedürfnisse und Wünsche an und generieren Sie ein Passwort für das vmail-Konto. Der Hash, der sich derzeit in dieser Datei befindet, setzt das Passwort auf schreibgeschützt
Geben Sie den folgenden Befehl ein, um den Hash für das vmail-Konto zu erstellen:
slappasswd -h {MD5}
Geben Sie das gewünschte Passwort zweimal ein und kopieren Sie das Ergebnis in den Text unten.
nano base.ldif
Inhalt von base.ldif
dn: o=hosting,dc=example,dc=tld
objectClass: organization
objectClass: top
o: hosting description: Hosting Organization
# Read only account
dn: cn=vmail,o=hosting,dc=example,dc=tld
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: vmail
userPassword: {MD5}M267sheb6qc0Ck8WIPOvQA==
description: Read only account
Laden Sie die Basis-DN mit dem folgenden Befehl in die Datenbank:
ldapmodify -a -D cn=admin,dc=example,dc=tld -W -f base.ldif
Jetzt müssen wir die ACLs ändern, damit jedem Benutzertyp der richtige Zugriff gewährt wird.
ldapmodify -Y EXTERNAL -H ldapi:/// -f acl-remove.ldif
ldapmodify -Y EXTERNAL -H ldapi:/// -f acl-new.ldif
Sie können die neuen ACLs mit dem folgenden Befehl überprüfen:
slapcat -n 0
Damit ist die OpenLDAP-Konfiguration abgeschlossen.
Schritt 3:Postfix installieren und konfigurieren
Zuvor benötigen wir den vmail-Benutzer und sein Home-Verzeichnis.
Erstellen Sie den vmail-Benutzer und die Gruppe:
useradd vmail
Standardmäßig wird auch die Gruppe vmail erstellt.
Unter /etc/passwd finden Sie die tatsächliche UID und Gruppennummer.
Erstellen Sie als Nächstes das vmail-Verzeichnis und legen Sie die Inhaberschaft für den vmail-Benutzer und die vmail-Gruppe fest.
mkdir /home/vmail
mkdir /home/vmail/domains
chown -R vmail:vmail /home/vmail
Führen Sie den folgenden Befehl aus, um Postfix und andere erforderliche Anwendungen zu installieren:
apt install postfix postfix-ldap
Ihnen werden zwei Fragen gestellt. Antworten Sie wie folgt:
Allgemeiner E-Mail-Konfigurationstyp: <--Standalone
System-E-Mail-Name: <-- mail.example.tld
Wir installieren kein sasl, da wir Dovecot LDA verwenden und liefern.
Nun erstellen wir die Zertifikate für TLS:
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
Hinweis:Sie können alle Dateien unter example/postfix in Ihr etc/postfix-Verzeichnis kopieren und entsprechende Änderungen vornehmen. Der Vollständigkeit halber gebe ich nachfolgend das komplette Setup an.
Jetzt konfigurieren wir postfix:
cd /etc/postfix
mv /etc/postfix/main.cf /etc/postfix/main.cf.bck
nano /etc/postfix/main.cf
Und fügen Sie Folgendes ein. Bitte beachten Sie, dass diese Konfiguration das Versenden (Weiterleiten) von Mails durch authentifizierte Benutzer erlaubt, und auch das Versenden lokaler Mails (wie zum Beispiel an root, postmaster, ...) an die entsprechenden Aliase, falls diese konfiguriert sind.
smtpd_banner =$myhostname ESMTP $mail_name
biff =no
# Das Anhängen von .domain ist Aufgabe des MUA.
append_dot_mydomain =no
# Entkommentieren Sie die nächste Zeile zum Generieren von "delay_warning_time"-Warnungen
delay_warning_time =4h
# TLS-Parameter
smtpd_tls_cert_file =/etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file =/etc /postfix/ssl/smtpd.key
smtpd_use_tls =yes
smtpd_tls_session_cache_database =btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database =btree:${queue_directory}/smtp_scache
myhostname =mail.example.tld
alias_maps =hash:/etc/aliases,
alias_database =hash:/etc/aliases
myorigin =localhost
relayhost =
mynetworks =127.0.0.0/8
dovecot_destination_recipient_limit =1
mailbox_command =/usr/lib/deliver
mailbox_size_limit =0
recipient_delimiter =+
inet_interfaces =all
inet_protocols =all
#smtp_bind_address =Ihre IP-Adresse (optional) ==>Markieren und ändern Sie die IP-Adresse für Ihr Setup.
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable =yes
smtpd_sasl_security_options =noanonymous
smtpd_sasl_type =dovecot
smtpd_sasl_path =private/auth
broken_sasl_auth_clients =ja
smtpd_tls_auth_only =nein
smtp_use_tls =ja
smtp_tls_note_starttls_offer =ja
smtpd_tls_CAfile =/etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel =1
smtpd_tls_received_header =ja
smtpd_tls_session_cache_timeout =3600s
tls_random_source =dev:/dev/urandom
home_mailbox =Maildir/
smtpd_recipient_restrictions =
permit_mynetworks permit_sasl_authenticated
reject_invalid_hostname reject_non_fqdn_hostname
reject_non_fqdn_sender reject_non_fqdn_recipient
reject_unauth_destination reject_unauth_pipelining
reject_invalid_hostname reject_unknown_sender_domain
ablehnen_ rbl_client list.dsbl.org
abgelehnt_rbl_client cbl.abuseat.org
abgelehnt_rhsbl_sender dsn.fc-ignorant.org
smtpd_data_restrictions =
abgelehnt_unauth_pipelining,
abgelehnt_multi_recipient_bounce,
Zulassung
smtpd_helo_required =yes
# transport_maps
maildrop_destination_concurrency_limit =2
maildrop_destination_recipient_limit =1
gnarwl_destination_concurrency_limit =1
gnarwl_destination_recipient_limit =1
transport_maps =hash:/etc/postfix/transport, ldap:/etc/postfix/ldap-transport.cf
mydestination =$transport_maps, localhost, localhost.localdomain, $myhostname, localhost .$mydomain, $mydomain
virtual_alias_maps =
ldap:/etc/postfix/ldap-aliases.cf,
ldap:/etc/postfix/ldap-virtualforward.cf,
ldap:/etc/postfix/ldap-accountsmap.cf
# virtuelle Konten für die Zustellung
virtual_mailbox_base =/home/vmail
virtual_mailbox_maps =
ldap :/etc/postfix/ldap-accounts.cf
virtual_minimum_uid =1000 ==> Ändern Sie dies in die tatsächliche UID des Benutzers vmail
virtual_uid_maps =static:1000 ==> Ändern Sie dies in die tatsächliche UID von die Benutzer-vmail
virtual_gid_maps =static:1000 ==> Ändern Sie dies in die aktuelle UID der Benutzer-vmail
local_recipient_maps =$alias_maps
recipient_bcc_maps =ldap:/ etc/postfix/ldap-vacation.cf
nano /etc/postfix/master.cf
Und fügen Sie Folgendes ein (fügen Sie das Ende hinzu):
dovecot unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient} gnarwl unix - n n - - pipe flags=F user=vmail argv=/usr/bin/gnarwl -a ${user}@${nexthop} -s ${sender}
Jetzt müssen wir die verschiedenen ldap-xxx.cf-Dateien schreiben
nano ldap-accounts.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readmonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(objectClass=VirtualMailAccount)(mail =%s))(forwardActive=FALSE)(accountActive=TRUE)(delete=FALSE))
result_attribute =Postfach
nano ldap-accounstmap.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(objectClass=VirtualMailAccount)(mail =%s))(forwardActive=FALSE)(accountActive=TRUE)(delete=FALSE))
result_attribute =mail
nano ldap-aliases.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(objectClass=VirtualMailAlias)(mail =%s))(accountActive=TRUE))
result_attribute =maildrop
nano ldap-transport.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(vd=%s)( objectClass=VirtualDomain))(accountActive=TRUE)(delete=FALSE))
result_attribute =postfixTransport
nano ldap-ferien.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(objectClass=VirtualMailAccount)(mail =%s))(vacationActive=TRUE)(forwardActive=FALSE)(accountActive=TRUE)(delete=FALSE))
result_attribute =mailAutoreply
nano ldap-virtualforward.cf
Und fügen Sie Folgendes ein:
server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn=vmail,o=hosting,dc=example,dc =tld
bind_pw =readonly
search_base =o=hosting,dc=example,dc=tld
scope =sub
query_filter =(&(&(objectClass=VirtualMailAccount)(mail =%s))(vacationActive=FALSE)(forwardActive=TRUE)(accountActive=TRUE)(delete=FALSE))
result_attribute =maildrop
Damit ist die Postfix-Einrichtung abgeschlossen.
Schritt 4:Dovecot installieren und konfigurieren
apt install dovecot-imapd dovecot-pop3d dovecot-ldap
Dadurch werden dovecot und alle erforderlichen Dateien installiert und auch die Standard-SSL-Zertifikate für IMAPs und POP3s erstellt.
Zuerst wechseln wir in das dovecot-Verzeichnis.
Hinweis:Sie können alle Dateien unter example/dovecot in Ihr etc/dovecot-Verzeichnis kopieren und entsprechende Änderungen vornehmen. Der Vollständigkeit halber gebe ich nachfolgend das komplette Setup an.
cd /etc/dovecot
Jetzt konfigurieren wir die verschiedenen Dovecot-Konfigurationsdateien.
nano dovecot-ldap.conf.ext
Und nehmen Sie die folgenden Änderungen vor:
hosts =localhost:389
ldap_version =3
auth_bind =ja
dn =cn=vmail,o=hosting,dc=beispiel,dc=tld
dnpass =schreibgeschützt
base =o=hosting,dc=hosting,dc=tld
scope =Teilbaum
deref =nie
user_attrs =quota=quota=maildir:storage
user_attrs =quota=quota=maildir:storage=%$B
user_filter =(&(objectClass=VirtualMailAccount)(accountActive=TRUE)(mail=%u))
pass_attrs =mail,userPassword
pass_filter =(&(objectClass=VirtualMailAccount)(accountActive=TRUE)(mail=%u))
default_pass_scheme =MD5
cd conf.d
vi 10-auth.conf
Und ändern Sie den Abschnitt Passwort und Benutzerdatenbanken in diesen:
#!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
vi 10-mail.conf
Und nehmen Sie die folgenden Änderungen vor:
mail_location =maildir:/home/vmail/%d/%u
mail_uid =1000 ==> auf den tatsächlichen vmail-uid-Wert ändern
mail_gid =1000 ==> ändere dies auf den aktuellen vmail gid-Wert
first_valid_uid =1000 ==> auf den tatsächlichen vmail-UID-Wert ändern
first_valid_gid =1000 ==> ändern Sie dies in den tatsächlichen vmail gid-Wert
vi 10-master.conf
Und nehmen Sie die folgenden Änderungen vor:
unix_listener auth-userdb {
mode =0666
user =vmail
group =vmail
}
# Postfix smtp-auth
unix_listener / var/spool/postfix/private/auth {
mode =0666
}
vi 15-lda.conf
Und nehmen Sie die folgenden Änderungen vor:
postmaster_address = [E-Mail-geschützt]
lda_mailbox_autocreate =ja
Damit ist die Dovecot-Konfiguration abgeschlossen.
Schritt 5:Gnarwl installieren und konfigurieren
Lassen Sie uns Gnarwl installieren:
apt install gnarwl
Lassen Sie uns nun Gnarwl konfigurieren.
Zuerst werden wir die ursprüngliche Konfigurationsdatei sichern und durch eine neue ersetzen.
mv /etc/gnarwl.conf /etc/gnarwl.conf.bck
Jetzt erstellen wir die neue conf-Datei:
vi /etc/gnarwl.conf
Und fügen Sie Folgendes ein:
map_sender $sender map_receiver $recepient map_subject $subject map_field $begin vacationStart map_field $end vacationEnd map_field $fullname cn map_field $deputy vacationForward map_field $reply mail server localhost port 389 scope sub login cn=vmail,o=hosting,dc=example,dc=tld password readonly protocol 0 base dc=example,dc=tld queryfilter (&(mailAutoreply=$recepient)(vacationActive=TRUE)) result vacationInfo blockfiles /var/lib/gnarwl/block/ umask 0644 blockexpire 48 mta /usr/sbin/sendmail -F $recepient -t $sender maxreceivers 64 maxheader 512 charset ISO8859-1 badheaders /var/lib/gnarwl/badheaders.db blacklist /var/lib/gnarwl/blacklist.db forceheader /var/lib/gnarwl/header.txt forcefooter /var/lib/gnarwl/footer.txt recvheader To Cc loglevel 3
Machen Sie das gnarwl-Verzeichnis für den vmail-Benutzer lesbar
chown -R vmail:vmail /var/lib/gnarwl/
Als nächstes müssen wir den gnarwl-Transport zu postfix
hinzufügenvi /etc/postfix/transport
Folgendes einfügen:
.autoreply gnarwl:
Jetzt müssen wir die transport.db
erstellenpostmap /etc/postfix/transport
Damit ist die Gnarwl-Konfiguration abgeschlossen.
Schritt 6:vMailpanel installieren und konfigurieren
Da wir vMailpanel zuvor heruntergeladen haben, können wir direkt mit der Konfiguration der vMailpanel-Oberfläche beginnen.
chown -R www-data:www-data /usr/share/phamm
cd /usr/share/vMailpanel
Jetzt werden wir phamm für den tatsächlichen Gebrauch konfigurieren.
cp config.inc.example.php config.inc.php
nano config.inc.php
Passen Sie die LDAP-Verbindungsparameter an Ihre aktuelle Konfiguration an.
// *============================* // *=== LDAP Server Settings ===* // *============================* // The server address (IP or FQDN) define ('LDAP_HOST_NAME','127.0.0.1'); // The protocol version [2,3] define ('LDAP_PROTOCOL_VERSION','3'); // The server port define ('LDAP_PORT','389'); // The container define ('SUFFIX','dc=example,dc=tld'); // The admin bind dn (could be rootdn) define ('BINDDN','cn=admin,dc=example,dc=tld'); // The Phamm container define ('LDAP_BASE','o=hosting,dc=example,dc=tld');
und ändern
// Welcome message define ('SEND_WELCOME',1); $welcome_msg = '../welcome_message.txt'; $welcome_subject = 'Welcome!'; # $welcome_sender = '[email protected]'; $welcome_bcc = '[email protected]';
Dadurch werden eine Willkommensnachricht und ein BCC an Ihr Postmaster-Konto gesendet.
Aktivieren Sie das fpt- und person-Plug-in, indem Sie das // im Plug-in-Abschnitt entfernen. Falls gewünscht, können Sie auch die Davical- und/oder Jabber-Plugins aktivieren, das für diese Plugins benötigte Schema wird installiert.
In der config.inc.php finden Sie:
define ('DELETE_ACCOUNT_IMMEDIATELY', false);
Wenn Sie dies auf „true“ setzen, wird die Konto- oder Domänenlöschung sofort wirksam. Das physische Postfach wird jedoch nicht gelöscht (oder das Domänenverzeichnis). Um das physische Postfach zu löschen, sollten wir das Skript cleaner.sh verwenden. Dies wird unten beschrieben.
Sie können plugins/mail.xml bearbeiten, um die Standardeinstellungen für SMTP und Kontingente zu ändern und sie an Ihre Bedürfnisse anzupassen. Der Standardwert ist auf ein Kontingent von 1 GB eingestellt.
Sie können plugins/ftp.xml bearbeiten, um die Standardeinstellungen für das standardmäßige FTP-Verzeichnis (Basisverzeichnis) und das Kontingent zu ändern und sie an Ihre Bedürfnisse anzupassen.
Vergessen Sie nicht, die Aliase und/oder Mailboxen für Postmaster, Webmaster zu erstellen, da diese von Beamten und ISPs verwendet werden, um E-Mails an sie zu senden, falls ... Wenn Sie diese Adressen nicht haben, könnte dies dazu führen, dass Sie auf die schwarze Liste gesetzt werden.
Standardmäßig werden die Aliase [E-Mail-geschützt] und [E-Mail-geschützt] erstellt, die standardmäßig [E-Mail-geschützt] werden.
Jetzt das sauberere Skript:
cp tools/cleaner.sh /home/vmail/cleaner.sh
Ändern Sie Folgendes in cleaner.sh
BINDDN="cn=admin,dc=example,dc=tld"
BINDPW="password"
LDAP_BASE="o=hosting,dc=example,dc=tld"
Um Ihre Installation widerzuspiegeln
nano /home/vmail/cleaner.sh
crontab -e
Folgendes einfügen:
*/10 * * * * /home/vmail/cleaner.sh
Dadurch wird das Cleaner-Skript alle 10 Minuten ausgeführt. Fühlen Sie sich frei, das Timing zu ändern.
Jetzt werden wir vMailpanel zu Apache hinzufügen
nano /etc/apache2/conf-enabled/000-default.conf
Und fügen Sie zwischen den Einträgen
Alias /vmailpanel /usr/share/vMailpanel/public
Damit ist die vMailpanel-Konfiguration abgeschlossen.
Schritt 7:Roundcube-Webmail installieren und konfigurieren
Zuerst erstellen wir eine Datenbank namens roundcube:
mysqladmin -u root -p create roundcube
Als nächstes gehen wir zur MySQL-Shell:
mysql -u root -p
Auf der MySQL-Shell erstellen wir den Benutzer roundcube mit dem Passwort roundcube_password (ersetzen Sie es durch ein Passwort Ihrer Wahl), der die Berechtigungen SELECT, INSERT, UPDATE, DELETE in der roundcube-Datenbank hat. Dieser Benutzer wird von Postfix und Courier verwendet, um eine Verbindung zur Roundcube-Datenbank herzustellen:
GRANT SELECT, INSERT, UPDATE, DELETE ON roundcube.* TO 'roundcube'@'localhost' IDENTIFIED BY 'roundcube_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON roundcube.* TO 'roundcube'@'localhost.localdomain' IDENTIFIED BY 'roundcube_password';
FLUSH PRIVILEGES;
Jetzt laden wir Roundcube herunter und installieren es:
cd/usr/src
wget https://github.com/roundcube/roundcubemail/releases/download/1.3.6/roundcubemail-1.3.6.tar.gz
tar xvzf roundcubemail-1.3.6.tar.gz
mv roundcubemail-1.3.6 /var/www/roundcube
chown -R www-data:www-data /var/www/roundcube
cd /var/www/roundcube
Suchen Sie immer nach der neuesten Version von Roundcube, laden Sie diese herunter und passen Sie die obigen Befehle an die Version von Roundcube an, die Sie heruntergeladen haben.
https://roundcube.net/download/
Jetzt laden wir die SQL-Tabellen in die zuvor erstellte Datenbank:
mysql -u roundcube -p roundcube < SQL/mysql.initial.sql
Jetzt bearbeiten wir die Roundcube-Konfiguration:
cp config/config.inc.php.sample config/config.inc.php
Legen Sie die Datenbankkonfiguration fest:
nano config/config.inc.php
Ändern Sie die folgende Zeile in die Datenbankkonfiguration:
$rcmail_config['db_dsnw'] = 'mysql://roundcube:[email protected]/roundcube';
Und ändern Sie Folgendes
Von:
// List of active plugins (in plugins/ directory) $config['plugins'] = array(
'archive',
'zipdownload',
An:
// List of active plugins (in plugins/ directory) $config['plugins'] = array(
'archive',
'zipdownload',
'password',
'vacation',
Änderung:
chars.$rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str';
An:
chars.$rcmail_config['des_key'] = 'your-own-24-digitkeystring';
Änderung:
$rcmail_config['default_host'] = '';
An:
$rcmail_config['default_host'] = 'localhost';
Änderung:
$rcmail_config['smtp_server'] = '';
An
$rcmail_config['smtp_server'] = 'localhost';
Die Konfiguration für das Passwort-Plugin:
cp plugins/password/config.inc.php.dist plugins/password/config.inc.php
Bearbeiten Sie die Konfiguration:
nano plugins/password/config.inc.php
Ändern Sie die folgenden Einträge
Von:
$rcmail_config['password_driver'] = 'sql';
An:
$rcmail_config['password_driver'] = 'ldap';
Von:
// LDAP Driver options // ------------------- // LDAP server name to connect to. // You can provide one or several hosts in an array in which case the hosts are tried from left to right. // Exemple: array('ldap1.exemple.com', 'ldap2.exemple.com'); // Default: 'localhost' $rcmail_config['password_ldap_host'] = 'localhost'; // LDAP server port to connect to // Default: '389' $rcmail_config['password_ldap_port'] = '389'; // TLS is started after connecting // Using TLS for password modification is recommanded. // Default: false $rcmail_config['password_ldap_starttls'] = false; // LDAP version // Default: '3' $rcmail_config['password_ldap_version'] = '3'; // LDAP base name (root directory) // Exemple: 'dc=exemple,dc=com' $rcmail_config['password_ldap_basedn'] = 'dc=exemple,dc=com'; // LDAP connection method // There is two connection method for changing a user's LDAP password. // 'user': use user credential (recommanded, require password_confirm_current=true) // 'admin': use admin credential (this mode require password_ldap_adminDN and password_ldap_adminPW) // Default: 'user' $rcmail_config['password_ldap_method'] = 'user'; // LDAP Admin DN // Used only in admin connection mode // Default: null $rcmail_config['password_ldap_adminDN'] = null; // LDAP Admin Password // Used only in admin connection mode // Default: null $rcmail_config['password_ldap_adminPW'] = null; // LDAP user DN mask // The user's DN is mandatory and as we only have his login, // we need to re-create his DN using a mask // '%login' will be replaced by the current roundcube user's login // '%name' will be replaced by the current roundcube user's name part // '%domain' will be replaced by the current roundcube user's domain part // Exemple: 'uid=%login,ou=people,dc=exemple,dc=com' $rcmail_config['password_ldap_userDN_mask'] = 'uid=%login,ou=people,dc=exemple,dc=com'; // LDAP password hash type // Standard LDAP encryption type which must be one of: crypt, // ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear. // Please note that most encodage types require external libraries // to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info. // Default: 'crypt' $rcmail_config['password_ldap_encodage'] = 'crypt'; // LDAP password attribute // Name of the ldap's attribute used for storing user password // Default: 'userPassword' $rcmail_config['password_ldap_pwattr'] = 'userPassword'; // LDAP password force replace // Force LDAP replace in cases where ACL allows only replace not read // See http://pear.php.net/package/Net_LDAP2/docs/latest/Net_LDAP2/Net_LDAP2_Entry.html#methodreplace // Default: true $rcmail_config['password_ldap_force_replace'] = true;
An:
$rcmail_config['password_ldap_host'] = 'localhost'; $rcmail_config['password_ldap_port'] = '389'; $rcmail_config['password_ldap_starttls'] = false; $rcmail_config['password_ldap_version'] = '3'; $rcmail_config['password_ldap_basedn'] = 'o=hosting,dc=example,dc=tld'; $rcmail_config['password_ldap_method'] = 'user'; $rcmail_config['password_ldap_adminDN'] = null; $rcmail_config['password_ldap_adminPW'] = null; $rcmail_config['password_ldap_userDN_mask'] = 'mail=%login,vd=%domain,o=hosting,dc=example,dc=tld'; $rcmail_config['password_ldap_encodage'] = 'md5'; $rcmail_config['password_ldap_pwattr'] = 'userPassword'; $rcmail_config['password_ldap_force_replace'] = true;
Jetzt werden wir das Urlaubs-Plugin herunterladen und installieren:
cd /usr/src
wget https://github.com/bhuisgen/rc-vacation/archive/master.zip
unzip rc-vacation-master.zip
mv rc-vacation /var/www/roundcube/plugins/vacation
cd /var/www/roundcube/plugins/vacation
Jetzt bearbeiten wir die Konfiguration und ändern:
nano plugins/vacation/config.inc.php
Änderung:
$rcmail_config['vacation_gui_vacationsubject'] = TRUE;
An:
$rcmail_config['vacation_gui_vacationsubject'] = FALSE;
Änderung:
$rcmail_config['vacation_driver'] = 'sql';
An:
$rcmail_config['vacation_driver'] = 'ldap';
Änderung:
// Base DN $rcmail_config['vacation_ldap_base'] = 'dc=ldap,dc=my,dc=domain'; // Bind DN $rcmail_config['vacation_ldap_binddn'] = 'cn=user,dc=ldap,dc=my,dc=domain'; // Bind password $rcmail_config['vacation_ldap_bindpw'] = 'pa$$w0rd';
An:
// Base DN $rcmail_config['vacation_ldap_base'] = 'o=hosting,dc=example,dc=tld'; // Bind DN $rcmail_config['vacation_ldap_binddn'] = 'cn=admin,dc=example,dc=tld'; // Bind password $rcmail_config['vacation_ldap_bindpw'] = 'yourpassword';
Änderung:
// Search filter to read data $rcmail_config['vacation_ldap_search_filter'] = '(objectClass=mailAccount)'; // Search attributes to read data $rcmail_config['vacation_ldap_search_attrs'] = array ('vacationActive', 'vacationInfo'); // array of DN to use for modify operations required to write data. $rcmail_config['vacation_ldap_modify_dns'] = array ( 'cn=%email_local,ou=Mailboxes,dc=%email_domain,ou=MailServer,dc=ldap,dc=my,dc=domain' );
An:
// Search base to read data $rcmail_config['vacation_ldap_search_base'] = 'mail=%username,vd=%email_domain,o=hosting,dc=example,dc=tld'; // Search filter to read data $rcmail_config['vacation_ldap_search_filter'] = '(objectClass=VirtualMailAccount)'; // Search attributes to read data $rcmail_config['vacation_ldap_search_attrs'] = array ('vacationActive', 'vacationInfo'); // array of DN to use for modify operations required to write data. $rcmail_config['vacation_ldap_modify_dns'] = array ( 'mail=%username,vd=%email_domain,o=hosting,dc=example,dc=tld' );
Wir müssen den Dokumentenstamm in der Apche2-Serverkonfiguration ändern, damit auf Roundcube zugegriffen werden kann.
nano /etc/apache2/sites-enabled/000-default.conf
Und ändern Sie von:
DocumentRoot /var/www/html
An:
DocumentRoot /var/www/
Damit ist die Konfiguration für Roundcube abgeschlossen.
Schritt 8:Installieren und konfigurieren Sie proftpd
Zuerst installieren wir proftpd und seine Anforderungen:
apt install proftpd proftpd-mod-ldap
Je nach Auslastung können Sie zwischen Stand Alone und inet.d entscheiden.
Hinweis:Sie können die Konfigurationsdateien von example/proftpd nach /etc/proftpd kopieren, aber der Klarheit halber werde ich alle Konfigurationsschritte skizzieren.
Bearbeiten Sie /etc/proftpd/proftpd.conf:
nano /etc/proftpd/proftpd.conf
Und ändern Sie von:
# Use this to jail all users in their homes # DefaultRoot ~
An:
# Use this to jail all users in their homes DefaultRoot
Und ändern Sie von:
#RequireValidShell off
An:
RequireValidShell off
And change:
# Alternative authentication frameworks
#
# Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf
To:
# Alternative authentication frameworks
#
Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf
~
Now edit /etc/proftpd/modules.conf:
nano /etc/proftpd/modules.conf
And change from:
# Install proftpd-mod-ldap to use this #LoadModule mod_ldap.c
To:
# Install proftpd-mod-ldap to use this LoadModule mod_ldap.c
And from:
# Install proftpd-mod-ldap to use this # LoadModule mod_quotatab_ldap.c
To:
# Install proftpd-mod-ldap to use this LoadModule mod_quotatab_ldap.c
No edit /etc/proftpd/ldap.conf and set the following:
<IfModule mod_ldap.c>
#
#LDAPServer ldap://ldap.example.com
#LDAPBindDN "cn=admin,dc=example,dc=com" "admin_password"
#LDAPUsers dc=users,dc=example,dc=com (uid=%u) (uidNumber=%u)
#LDAPUseTLS on
#
#
#LDAPServer ldaps://ldap.example.com
#LDAPBindDN "cn=admin,dc=example,dc=com" "admin_password"
#LDAPUsers dc=users,dc=example,dc=com (uid=%u) (uidNumber=%u)
#
LDAPServer ldap://127.0.0.1/??sub
LDAPBindDN "cn=vmail,o=hosting,dc=example,dc=tld "readonly"
LDAPUsers "o=hosting,dc=example,dc=tld" "(&(uid=%v)(objectclass=posixAccount))"
LDAPDefaultGID 33
LDAPDefaultUID 33
LDAPForceDefaultGID True
LDAPForceDefaultUID True
</IfModule>
The following commands set the default user to www-data which suits me, you can change these values to suit your setup or leave them out to use the login uid / gid.
LDAPDefaultGID 33
LDAPDefaultUID 33
LDAPForceDefaultGID True
LDAPForceDefaultUID True
33 Is the uid/gid of my testing setup, it can be different on your setup.
This concludes the proftpd installation.
Step 9:Bringing it all together
Issue the following commands to restart all of the services:
service slapd restart
service postfix restart
service dovecot restart
service proftpd restart
service apache2 restart
Now you can go to phamm and start adding mail domains and users.
Enjoy.
Note:notify me of any errors or problems with this how to so I can improve and amend this how to.
Use this thread in the forum:
https://www.howtoforge.com/community/threads/postfix-virtual-hosting-with-ldap-backend-and-with-dovecot-as-imap-pop3-server-on-ubuntu-bionic-beav.79408/
I am subscribed to this thread so I will get notifications of new posts in this thread.