在 CentOS 上搭建加密的邮件服务器,通常包含三层加密:传输加密(TLS/SSL)、用户认证加密、磁盘/存储加密。下面按常见场景给你一套实用方案。
常见组合:
推荐使用免费证书:
yum install certbot
certbot certonly --standalone -d mail.example.com
证书路径:
/etc/letsencrypt/live/mail.example.com/fullchain.pem
/etc/letsencrypt/live/mail.example.com/privkey.pem
编辑 /etc/postfix/main.cf:
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem
smtpd_use_tls = yes
smtpd_tls_security_level = encrypt
smtp_tls_security_level = may
强制提交端口加密(587):
smtpd_tls_auth_only = yes
编辑 /etc/dovecot/conf.d/10-ssl.conf:
ssl = required
ssl_cert = </etc/letsencrypt/live/mail.example.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.example.com/privkey.pem
禁用明文登录:
disable_plaintext_auth = yes
Dovecot 默认使用:
示例:
doveadm pw -s SHA512-CRYPT
确保:
STARTTLSIMAPS / POP3S端口建议:
用户端加密:
服务器不解密,仅转发。
安装时选择:
Encrypt my data
或后期加密数据盘:
cryptsetup luksFormat /dev/sdb1
firewall-cmd --add-service={smtp,submission,imaps,pop3s} --permanent
firewall-cmd --reload
建议:
Internet
↓ TLS
Postfix (25/465/587)
↓
Dovecot (993/995)
↓
Maildir (LUKS)
如果你告诉我:
我可以直接给你完整可复制配置文件。