自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

OpenSSL在Apache和Dovecot 下的使用(二)

系統(tǒng) Linux 系統(tǒng)運(yùn)維
在上周,作為我們 OpenSSL 系列的一部分,我們學(xué)習(xí)了如何配置 Apache 以使用 OpenSSL 并強(qiáng)制所有會(huì)話使用 HTTPS。 今天,我們將使用 OpenSSL 保護(hù)我們的 Postfix/Dovecot 郵件服務(wù)器。

[[182555]]

本篇中,Carla Schroder 會(huì)解釋如何使用 OpenSSL 保護(hù)你的 Postfix/Dovecot 郵件服務(wù)器

在上周,作為我們 OpenSSL 系列的一部分,我們學(xué)習(xí)了如何配置 Apache 以使用 OpenSSL 并強(qiáng)制所有會(huì)話使用 HTTPS。 今天,我們將使用 OpenSSL 保護(hù)我們的 Postfix/Dovecot 郵件服務(wù)器。這些示例基于前面的教程; 請(qǐng)參閱***的參考資料部分,了解本系列中以前的所有教程的鏈接。

你需要配置 Postfix 以及 Dovecot 都使用 OpenSSL,我們將使用我們?cè)贠penSSL 在 Apache 和 Dovecot 下的使用(一)中創(chuàng)建的密鑰和證書。

Postfix 配置

你必須編輯 /etc/postfix/main.cf 以及 /etc/postfix/master.cf。實(shí)例的 main.cf 是完整的配置,基于我們先前的教程。替換成你自己的 OpenSSL 密鑰和證書名以及本地網(wǎng)絡(luò)地址。

  1. compatibility_level=2 
  2. smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu/GNU) 
  3. biff = no 
  4. append_dot_mydomain = no 
  5. myhostname = localhost 
  6. alias_maps = hash:/etc/aliases 
  7. alias_database = hash:/etc/aliases 
  8. myorigin = $myhostname 
  9. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24 
  10. mailbox_size_limit = 0 
  11. recipient_delimiter = + 
  12. inet_interfaces = all 
  13. virtual_mailbox_domains = /etc/postfix/vhosts.txt 
  14. virtual_mailbox_base = /home/vmail 
  15. virtual_mailbox_maps = hash:/etc/postfix/vmaps.txt 
  16. virtual_minimum_uid = 1000 
  17. virtual_uid_maps = static:5000 
  18. virtual_gid_maps = static:5000 
  19. virtual_transport = lmtp:unix:private/dovecot-lmtp 
  20. smtpd_tls_cert_file=/etc/ssl/certs/test-com.pem 
  21. smtpd_tls_key_file=/etc/ssl/private/test-com.key 
  22. smtpd_use_tls=yes 
  23. smtpd_sasl_auth_enable = yes 
  24. smtpd_sasl_type = dovecot 
  25. smtpd_sasl_path = private/auth 
  26. smtpd_sasl_authenticated_header = yes 

在 master.cf 取消 submission inet 部分的注釋,并編輯 smtpd_recipient_restrictions:

  1. #submission inet n  -  y  -  - smtpd 
  2.   -o syslog_name=postfix/submission 
  3.   -o smtpd_tls_security_level=encrypt 
  4.   -o smtpd_sasl_auth_enable=yes 
  5.   -o milter_macro_daemon_name=ORIGINATING 
  6.   -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject 
  7.   -o smtpd_tls_wrappermode=no 

完成后重新加載 Postfix:

  1. $ sudo service postfix reload 

Dovecot 配置

在我們以前的教程中,我們?yōu)?Dovecot 創(chuàng)建了一個(gè)單一配置文件 /etc/dovecot/dovecot.conf,而不是使用多個(gè)默認(rèn)配置文件。這是一個(gè)基于我們以前的教程的完整配置。再說一次,使用你自己的 OpenSSL 密鑰和證書,以及你自己的 userdb 的 home 文件:

  1. protocols = imap pop3 lmtp 
  2. log_path = /var/log/dovecot.log 
  3. info_log_path = /var/log/dovecot-info.log 
  4. disable_plaintext_auth = no 
  5. mail_location = maildir:~/.Mail 
  6. pop3_uidl_format = %g 
  7. auth_mechanisms = plain 
  8. passdb { 
  9.   driver = passwd-file 
  10.   args = /etc/dovecot/passwd 
  11. userdb { 
  12.   driver = static 
  13.   args = uid=vmail gid=vmail home=/home/vmail/studio/%u 
  14. service lmtp { 
  15.  unix_listener /var/spool/postfix/private/dovecot-lmtp { 
  16.    group = postfix 
  17.    mode = 0600 
  18.    user = postfix 
  19.   } 
  20. protocol lmtp { 
  21.   postmaster_address = postmaster@studio 
  22. service lmtp { 
  23.   user = vmail 
  24. service auth { 
  25.   unix_listener /var/spool/postfix/private/auth { 
  26.     mode = 0660 
  27.         user=postfix 
  28.         group=postfix 
  29.   } 
  30.  } 
  31. ssl=required 
  32. ssl_cert = </etc/ssl/certs/test-com.pem 
  33. ssl_key = </etc/ssl/private/test-com.key 

重啟 Dovecot:

  1. $ sudo service postfix reload 

用 telnet 測(cè)試

就像我們以前一樣,現(xiàn)在我們可以通過使用 telnet 發(fā)送消息來測(cè)試我們的設(shè)置。 但是等等,你說 telnet 不支持 TLS/SSL,那么這樣怎么辦呢?首先通過使用 openssl s_client 打開一個(gè)加密會(huì)話。openssl s_client 的輸出將顯示你的證書及其指紋和大量其它信息,以便你知道你的服務(wù)器正在使用正確的證書。會(huì)話建立后輸入的命令都是不以數(shù)字開頭的:

  1. $ openssl s_client -starttls smtp -connect studio:25 
  2. CONNECTED(00000003) 
  3. [masses of output snipped] 
  4.     Verify return code: 0 (ok) 
  5. --- 
  6. 250 SMTPUTF8 
  7. EHLO studio 
  8. 250-localhost 
  9. 250-PIPELINING 
  10. 250-SIZE 10240000 
  11. 250-VRFY 
  12. 250-ETRN 
  13. 250-AUTH PLAIN 
  14. 250-ENHANCEDSTATUSCODES 
  15. 250-8BITMIME 
  16. 250-DSN 
  17. 250 SMTPUTF8 
  18. mail from: <carla@domain.com> 
  19. 250 2.1.0 Ok 
  20. rcpt to: <alrac@studio> 
  21. 250 2.1.5 Ok 
  22. data 
  23. 354 End data with .subject: TLS/SSL test 
  24. Hello, we are testing TLS/SSL. Looking good so far. 
  25. 250 2.0.0 Ok: queued as B9B529FE59 
  26. quit 
  27. 221 2.0.0 Bye 

你應(yīng)該可以在郵件客戶端中看到一條新郵件,并在打開時(shí)要求你驗(yàn)證 SSL 證書。你也可以使用 openssl s_client 來測(cè)試 Dovecot 的 POP3 和 IMAP 服務(wù)。此示例測(cè)試加密的 POP3,第 5 號(hào)消息是我們?cè)?telnet(如上)中創(chuàng)建的:

  1. $ openssl s_client -connect studio:995 
  2. CONNECTED(00000003) 
  3. [masses of output snipped] 
  4.     Verify return code: 0 (ok) 
  5. --- 
  6. +OK Dovecot ready 
  7. user alrac@studio  
  8. +OK 
  9. pass password 
  10. +OK Logged in
  11. list 
  12. +OK 5 messages: 
  13. 1 499 
  14. 2 504 
  15. 3 514 
  16. 4 513 
  17. 5 565 
  18. retr 5 
  19. +OK 565 octets 
  20. Return-Path: <carla@domain.com> 
  21. Delivered-To: alrac@studio 
  22. Received: from localhost 
  23.         by studio.alrac.net (Dovecot) with LMTP id y8G5C8aablgKIQAAYelYQA 
  24.         for <alrac@studio>; Thu, 05 Jan 2017 11:13:10 -0800 
  25. Received: from studio (localhost [127.0.0.1]) 
  26.         by localhost (Postfix) with ESMTPS id B9B529FE59 
  27.         for <alrac@studio>; Thu,  5 Jan 2017 11:12:13 -0800 (PST) 
  28. subject: TLS/SSL test 
  29. Message-Id: <20170105191240.B9B529FE59@localhost> 
  30. Date: Thu,  5 Jan 2017 11:12:13 -0800 (PST) 
  31. From: carla@domain.com 
  32. Hello, we are testing TLS/SSL. Looking good so far. 
  33. quit 
  34. +OK Logging out
  35. closed 

現(xiàn)在做什么?

現(xiàn)在你有一個(gè)功能良好的,具有合適的 TLS/SSL 保護(hù)的郵件服務(wù)器了。我鼓勵(lì)你深入學(xué)習(xí) Postfix 以及 Dovecot; 這些教程中的示例盡可能地簡(jiǎn)單,不包括對(duì)安全性、防病毒掃描程序、垃圾郵件過濾器或任何其他高級(jí)功能的調(diào)整。我認(rèn)為當(dāng)你有一個(gè)基本工作系統(tǒng)時(shí)更容易學(xué)習(xí)高級(jí)功能。

下周回到 openSUSE 包管理備忘錄上。

資源

責(zé)任編輯:龐桂玉 來源: Linux中國(guó)
相關(guān)推薦

2010-05-12 18:05:45

linux下subvesubversionapache配置

2013-01-24 09:29:16

2016-09-06 21:55:10

LinuxOpenSSLiOS

2009-12-10 10:18:44

Apache安裝

2011-11-24 21:12:35

ibmdw

2010-05-14 09:04:18

Subversion1

2015-08-27 09:41:30

LinuxRAID

2010-05-18 18:28:05

安裝Subversio

2015-08-25 09:35:17

LinuxRAID

2024-10-23 20:09:47

2010-01-22 10:51:54

svn命令linux

2011-09-05 13:19:42

UbuntuWebmin

2011-03-14 13:07:22

LAMPApache調(diào)優(yōu)

2014-07-30 14:35:33

LinuxApache

2022-07-12 14:04:19

Kafka

2010-06-02 13:05:52

tomcat和svn

2011-09-01 16:59:28

UbuntuApache

2022-09-16 08:23:22

Flink數(shù)據(jù)湖優(yōu)化

2011-03-28 10:42:00

Spring

2009-03-06 16:11:49

RHEL5SendmailDovecot
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)