Dovecot

도훈이집
둘러보기로 이동 검색으로 이동

Dovecot 개요[편집 | 원본 편집]

  • FreeBSD에 Dovecot 설치.

Dovecot 설치[편집 | 원본 편집]

  • 특별한 옵션이 없으므로 pkg를 사용 한다.
pkg install dovecot
또는
cd /usr/ports/mail/dovecot && make install clean
메세지 출력
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	dovecot: 2.3.20_1

Number of packages to be installed: 1

The process will require 22 MiB more space.
5 MiB to be downloaded.

Proceed with this action? [y/N]: y
[mail.zbb.kr] [1/1] Fetching dovecot-2.3.20_1.pkg: 100%    5 MiB   4.8MB/s    00:01    
Checking integrity... done (0 conflicting)
[mail.zbb.kr] [1/1] Installing dovecot-2.3.20_1...
===> Creating groups.
Creating group 'dovecot' with gid '143'.
Creating group 'dovenull' with gid '144'.
===> Creating users
Creating user 'dovecot' with uid '143'.
Creating user 'dovenull' with uid '144'.
[mail.zbb.kr] [1/1] Extracting dovecot-2.3.20_1: 100%
=====
Message from dovecot-2.3.20_1:

--
You must create the configuration files yourself. Copy them over
 to /usr/local/etc/dovecot and edit them as desired:

 	cp -R /usr/local/etc/dovecot/example-config/* \
 		/usr/local/etc/dovecot

 The default configuration includes IMAP and POP3 services, will
 authenticate users agains the system's passwd file, and will use
 the default /var/mail/$USER mbox files.

 Next, enable dovecot in /etc/rc.conf:

 	dovecot_enable="YES"


 To avoid a risk of mailbox corruption, do not set the
 security.bsd.see_other_uids or .see_other_gids sysctls to 0
 if Dovecot is storing mail for multiple concurrent users (PR 218392).

 Similarly, setting sysctls security.bsd.hardlink_check_uid or
 security.bsd.hardlink_check_gid to 1 might result in non-working
 mailboxes, depending on what mailbox locking mechanism is used
 (PR 242223).

 If you want to be able to search within attachments using the
 decode2text plugin, you'll need to install textproc/catdoc, and
 one of graphics/xpdf or graphics/poppler-utils.


 There are some potentially breaking changes in Dovecot 2.3. If you
 are upgrading from Dovecot 2.2:
 
   * Read https://wiki2.dovecot.org/Upgrading/2.3
   * Merge the configuration file changes from
     /usr/local/etc/dovecot/examples-config/

Dovecot 환경 설정[편집 | 원본 편집]

  • 에디터 vi /etc/rc.conf 파일에 등록 또는 아래 명령어로 한다.
sysrc dovecot_enable="YES" 
  • 설치 후 dovecot.conf의 예는 다음, /usr/local/etc/dovecot/example-config/ 에 있으므로 내용을 통째로 /usr/local/etc/dovecot/ 아래에 복사
cp -R /usr/local/etc/dovecot/example-config/* /usr/local/etc/dovecot
  • dovecot.conf 파일 권한 설정.
chmod 640 /usr/local/etc/dovecot/dovecot.conf
  • 에디터 vi /usr/local/etc/dovecot/dovecot.conf 파일을 열어 설정.
  • 참고로 imaps pop3s 설정시 제거 하라고 에러 출력 되므로 아래와 같이 수정 한다.
  • 소켓 에러시 listen = *, :: -----> listen = * 로 수정 한다.( 주석도 잘 제거!!, 제거 안 되면 시작 안 함.)
protocols = imap pop3
listen = * 
!include conf.d/*.conf
!include_try local.conf
  • 에디터 vi /usr/local/etc/dovecot/conf.d/10-ssl.conf 파일을 열어 설정
  1. DovecotConfiguration 참고.[1]
  2. ssl = yes 및 disable_plaintext_auth = yes 인 경우 SSL/TLS가 클라이언트에 제공되지만 클라이언트가 이를 사용할 필요는 없다.
  3. 보안 수준에 따라 인증은 완전히 안전하거나 공격을 받을 수있는 방법이 있을 수 있다.
  4. ssl = requireddisable_plaintext_auth = yes : 비 일반 텍스트 인증 메커니즘을 사용하더라도 SSL/TLS는 항상 필요로 한다.(좀더 안전한 방법)
  5. SSL/TLS를 사용하기 전에 인증을 시도하면 인증이 실패한다.
  6. SSL/TLS 설정 참고.[2]
  7. 제일 상단에 추가하고 나머지는 줄은 삭제하거나 주석 처리한다.
ssl = required
ssl_cert = </usr/local/etc/letsencrypt/live/zbb.kr/cert.pem
ssl_key = </usr/local/etc/letsencrypt/live/zbb.kr/privkey.pem
ssl_ca = </usr/local/etc/letsencrypt/live/zbb.kr/chain.pem  
ssl_verify_client_cert = yes
#ssl_dh = </etc/ssl/certs/dhparam_4096.pem 
ssl_min_protocol = TLSv1.2
# SSL ciphers to use, the default is: 
ssl_cipher_list = ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH
ssl_prefer_server_ciphers = yes
  • 에디터 vi /usr/local/etc/dovecot/conf.d/10-master.conf 파일을 열어 Postfix smtp-auth부분 설정.
 [.........]
 service imap-login {
   inet_listener imap {
     port = 0
   }
   inet_listener imaps {
     port = 993
     ssl = yes
    }
 }
  
 service pop3-login {
   inet_listener pop3 {
     port = 0
   }
  inet_listener pop3s {
     port = 995
     ssl = yes
   }
 }
  
 [.........]
 
  # Postfix smtp-auth
   unix_listener /var/spool/postfix/private/auth {
      mode = 0666
      user = postfix
      group = postfix
   }
 
 }
 
 [.....]

Dovecot 10-master.conf 설정 파일[편집 | 원본 편집]

Dovecot 10-auth.conf 설정[편집 | 원본 편집]

  • 에디터 vi /usr/local/etc/dovecot/conf.d/10-auth.conf 파일을 열어 수정.
  1. disable_plaintext_auth = no, 클라이언트측에서 일반 텍스트 인증을 사용하여 로그인 할 수 있다.
  2. disable_plaintext_auth = yes, 클라이언트측에서 일반텍스트 인증을 사용 할 수 없다. (조금 더 안전한 방법)
  3. SSL을 사용하여 인증 하므로 아래와 같이 설정 한다.
10, 100, 122 라인 쯤에
disable_plaintext_auth = yes
auth_mechanisms = plain login
!include auth-system.conf.ext 
  • 에디터 vi /usr/local/etc/dovecot/conf.d/10-mail.conf 파일을 열어 수정.
24라인 쯤에
mail_location = maildir:~/Maildir

Dovecot 환경 설정 복사[편집 | 원본 편집]

  • 서버 구축시 편집 반복을 피하기 위해서, 백업본이 있다면 사용 한다.
  • 우선 버전이 같어야 문제 없음, 사용자 디렉토리에 업로드 후 작업이 끝나면 삭제 한다.
cp /home/ssam/10-ssl.conf /usr/local/etc/dovecot/conf.d/10-ssl.conf
cp /home/ssam/10-master.conf /usr/local/etc/dovecot/conf.d/10-master.conf

Dovecot 서버 시작/재시작[편집 | 원본 편집]

service dovecot restart
service dovecot status


참고[편집 | 원본 편집]

  1. Timo Sirainen, SSL Configuration Generator (v2.2.31:https://doc.dovecot.org/configuration_manual/dovecot_ssl_configuration, 2023-12-05), 1.
  2. 모질라 재단, SSL Configuration Generator (v2.2.31:https://ssl-config.mozilla.org, 2023-12-05), 1.