mailcow-dockerized-docs/docs/u_e-dovecot-mail-crypt.md

33 Zeilen
1,2 KiB
Markdown

Mails are stored compressed (lz4) and encrypted. The key pair can be found in crypt-vol-1.
2018-10-12 21:53:35 +02:00
If you want to decode/encode existing maildir files, you can use the following script at your own risk:
2018-10-15 19:34:17 +02:00
Enter Dovecot by running `docker-compose exec dovecot-mailcow /bin/bash` in the mailcow-dockerized location.
2018-10-12 21:53:35 +02:00
```
# Decrypt /var/vmail
2019-01-27 20:13:43 +01:00
find /var/vmail/ -type f -regextype egrep -regex '.*S=.*W=.*' | while read -r file; do
2018-10-12 21:53:35 +02:00
if [[ $(head -c7 "$file") == "CRYPTED" ]]; then
doveadm fs get compress lz4:0:crypt:private_key_path=/mail_crypt/ecprivkey.pem:public_key_path=/mail_crypt/ecpubkey.pem:posix:prefix=/ \
2018-10-12 21:53:35 +02:00
"$file" > "/tmp/$(basename "$file")"
2019-12-22 16:52:45 +01:00
if [[ -s "/tmp/$(basename "$file")" ]]; then
chmod 600 "/tmp/$(basename "$file")"
chown 5000:5000 "/tmp/$(basename "$file")"
mv "/tmp/$(basename "$file")" "$file"
else
rm "/tmp/$(basename "$file")"
fi
2018-10-12 21:53:35 +02:00
fi
done
# Encrypt /var/vmail
2019-01-27 20:13:43 +01:00
find /var/vmail/ -type f -regextype egrep -regex '.*S=.*W=.*' | while read -r file; do
2018-10-12 21:53:35 +02:00
if [[ $(head -c7 "$file") != "CRYPTED" ]]; then
doveadm fs put crypt private_key_path=/mail_crypt/ecprivkey.pem:public_key_path=/mail_crypt/ecpubkey.pem:posix:prefix=/ \
"$file" "$file"
chmod 600 "$file"
chown 5000:5000 "$file"
fi
done
```