其中,卡拉施罗德介绍了如何使用OpenSSL保护作为Postfix/Dovecot邮件服务器的卡拉施罗德
正文导航-Postfix配置…… 10%
-Dovecot构成…… 32%
用telnet进行测试…… 48%
现在做什么? …… 76%
- -资源…… 81%
编译来源: https://www.Linux.com/learn/intro-Linux/OpenSSL-Apache-and-dovecot-part-2作者: CARLA SCHRODER
译者: geekpi
本文介绍了Carla Schroder如何使用OpenSSL保护Postfix/Dovecot邮件服务器
在上周的[1]中,作为OpenSSL系列的一部分,我们学习了如何将Apache配置为使用OpenSSL,以及如何在所有会话中强制使用HTTPS。 今天,我们将使用OpenSSL保护Postfix/Dovecot邮件服务器。 这些示例基于上一个教程。 有关本系列以前所有教程的链接,请参见最后的参考资料部分。
必须将OpenSSL配置为在Postfix和Dovecot上都使用。 在Apache和Dovecot中使用OpenSSL)使用在[2]中创建的密钥和证书。
必须编辑
Postfix 配置
/etc/postfix /主文件和/etc/postfix /主文件。 的main.cf实例是基于以前的教程的完整配置。 用您自己的OpenSSL密钥、证书名称和本地网络地址替换。compatibility _ level=2smtpd _ banner=$我的主机名称$邮件名称(Ubuntu/GNU ) )。
biff=no否
append _ dot _ my域=否
我的主机名称=本地主机
alias _ maps=散列:/ETC /别名
alias _数据库=散列:/ETC /别名
myorigin=$ my主机名称
my networks=127.0.0.0/8 [ :3360127.0.0.0 ]/104 [ :33601 ]/128192.168.0.0/24
邮箱_大小_限制=0
recipient _分隔符=
net _接口=全部
virtual _邮箱_域=/etc/postfix/vhosts.txt
虚拟邮箱=/主页/邮件
virtual _ mailbox _ maps=混合:/etc/postfix/vmaps.txt
virtual _最小_ uid=1000
virtual _ uid _ maps=静态33605000
virtual _ GID _ maps=静态33605000
virtual _ transport=lmtp : UNIX :专用/文档- lmtp
smtpd _ TLS _ cert _ file=/etc/SSL/certs /测试- com.PEM
smtpd _ TLS _密钥文件=/etc/SSL /私有/测试-密钥
smtpd _ use _ TLS=是
smtpd _ sasl _ auth _ enable=是
smtpd _ sasl _ type=文件
smtpd _ sasl _路径=私有/自动
smtpd _ sasl _认证_标头=是
在master.cf中,取消注释submission inet部分,然后编辑smtpd_recipient_restrictions。
# # submissioninetn-y-- smtpd-o系统日志_名称=postfix/submission
- o smtpd _ TLS _安全_级别=加密
- o smtpd _ sasl _ auth _ enable=是
- o milter _ macro _ daemon _ name=原始值
- o smtpd _ recipient _ restrictions=权限我的网络,权限我的权威
ed,reject-o smtpd_tls_wrappermode=no
完成后重新加载 Postfix:
$ sudo service postfix reloadDovecot 配置
在我们以前的教程中,我们为 Dovecot 创建了一个单一配置文件 /etc/dovecot/dovecot.conf,而不是使用多个默认配置文件。这是一个基于我们以前的教程的完整配置。再说一次,使用你自己的 OpenSSL 密钥和证书,以及你自己的 userdb 的 home 文件:
protocols = imap pop3 lmtplog_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot-info.log
disable_plaintext_auth = no
mail_location = maildir:~/.Mail
pop3_uidl_format = %g
auth_mechanisms = plain
passdb {
driver = passwd-file
args = /etc/dovecot/passwd
}
userdb {
driver = static
args = uid=vmail gid=vmail home=/home/vmail/studio/%u
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
protocol lmtp {
postmaster_address = postmaster@studio
}
service lmtp {
user = vmail
}
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user=postfix
group=postfix
}
}
ssl=required
ssl_cert = </etc/ssl/certs/test-com.pem
ssl_key = </etc/ssl/private/test-com.key
重启 Dovecot:
$ sudo service postfix reload用 telnet 测试
就像我们以前一样,现在我们可以通过使用 telnet 发送消息来测试我们的设置。 但是等等,你说 telnet 不支持 TLS/SSL,那么这样怎么办呢?首先通过使用 openssl s_client 打开一个加密会话。openssl s_client 的输出将显示你的证书及其指纹和大量其它信息,以便你知道你的服务器正在使用正确的证书。会话建立后输入的命令都是不以数字开头的:
$ openssl s_client -starttls smtp -connect studio:25CONNECTED(00000003)
[masses of output snipped]
Verify return code: 0 (ok)
---
250 SMTPUTF8
yqdsp studio
250-localhost
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
mail from: <carla@domain.com>
250 2.1.0 Ok
rcpt to: <alrac@studio>
250 2.1.5 Ok
data
354 End data with .subject: TLS/SSL test
Hello, we are testing TLS/SSL. Looking good so far.
.
250 2.0.0 Ok: queued as B9B529FE59
quit
221 2.0.0 Bye
你应该可以在邮件客户端中看到一条新邮件,并在打开时要求你验证 SSL 证书。你也可以使用 openssl s_client 来测试 Dovecot 的 POP3 和 IMAP 服务。此示例测试加密的 POP3,第 5 号消息是我们在 telnet(如上)中创建的:
$ openssl s_client -connect studio:995CONNECTED(00000003)
[masses of output snipped]
Verify return code: 0 (ok)
---
+OK Dovecot ready
user alrac@studio
+OK
pass password
+OK Logged in.
list
+OK 5 messages:
1 499
2 504
3 514
4 513
5 565
.
retr 5
+OK 565 octets
Return-Path: <carla@domain.com>
Delivered-To: alrac@studio
Received: from localhost
by studio.alrac.net (Dovecot) with LMTP id y8G5C8aablgKIQAAYelYQA
for <alrac@studio>; Thu, 05 Jan 2017 11:13:10 -0800
Received: from studio (localhost [127.0.0.1])
by localhost (Postfix) with ESMTPS id B9B529FE59
for <alrac@studio>; Thu, 5 Jan 2017 11:12:13 -0800 (PST)
subject: TLS/SSL test
Message-Id: <20170105191240.B9B529FE59@localhost>
Date: Thu, 5 Jan 2017 11:12:13 -0800 (PST)
From: carla@domain.com
Hello, we are testing TLS/SSL. Looking good so far.
.
quit
+OK Logging out.
closed
现在做什么?
现在你有一个功能良好的,具有合适的 TLS/SSL 保护的邮件服务器了。我鼓励你深入学习 Postfix 以及 Dovecot; 这些教程中的示例尽可能地简单,不包括对安全性、防病毒扫描程序、垃圾邮件过滤器或任何其他高级功能的调整。我认为phdmf有一个基本工作系统时更容易学习高级功能。
下周回到 openSUSE 包管理备忘录上。
资源
为 Apache 和 Dovecot 使用 OpenSSL[3]
如何在 Ubuntu Linux 上构建电子邮件服务器[4]
在 Ubuntu Linux 上构建电子邮件服务器:第2部分[5]
在 Ubuntu Linux 上构建电子邮件服务器:第3部分[6]
给初学者看的在 Ubuntu Linux 上使用 Apache[7]
给初学者看的在 Ubuntu Linux 上使用 Apache:第二部分[8]
给初学者看的在 CentOS Linux 上使用 Apache[9]
消灭让人害怕的 web 浏览器 SSL 警告[10]
via: https://www.linux.com/learn/intro-to-linux/openssl-apache-and-dovecot-part-2
作者:CARLA SCHRODER[11] 译者:geekpi 校对:校对者ID
本文由 LCTT[12] 原创编译,Linux中国 荣誉推出
[1]: https://linux.cn/article-8167-1.html
[2]: https://linux.cn/article-8167-1.html
[3]: https://linux.cn/article-8167-1.html
[4]: https://linux.cn/article-8071-1.html
[5]: https://linux.cn/article-8077-1.html
[6]: https://linux.cn/article-8088-1.html
[7]: https://www.linux.com/learn/apache-ubuntu-linux-beginners
[8]: https://www.linux.com/learn/apache-ubuntu-linux-beginners-part-2
[9]: https://www.linux.com/learn/apache-centos-linux-beginners
[10]: https://www.linux.com/learn/quieting-scary-web-browser-ssl-alerts
[11]: https://www.linux.com/users/cschroder
[12]: https://github.com/LCTT/TranslateProject