서버 설정 · 5 min read · Nov 04, 2025

완벽한 서버 - 우분투 매버릭 미어캣 (우분투 10.10) [ISPConfig 2] - 페이지 5

15 Postfix With SMTP-AUTH And TLS

Postfix를 SMTP-AUTH 및 TLS와 함께 설치하려면 다음 단계를 수행하십시오:

aptitude install postfix libsasl2-2 sasl2-bin libsasl2-modules procmail

두 가지 질문이 표시됩니다. 다음과 같이 답하십시오:

일반 메일 구성 유형: <– 인터넷 사이트
시스템 메일 이름: <– server1.example.com

그런 다음 실행하십시오

dpkg-reconfigure postfix

다시 몇 가지 질문이 표시됩니다:

일반 메일 구성 유형: <– 인터넷 사이트
시스템 메일 이름: <– server1.example.com
루트 및 포스트마스터 메일 수신자: <– [빈칸]
메일을 수신할 다른 목적지 (없으면 빈칸): <– server1.example.com, localhost.example.com, localhost.localdomain, localhost
메일 큐에서 동기식 업데이트 강제 적용? <– 아니요
로컬 네트워크: <– 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
로컬 배달에 procmail 사용? <– 예
메일박스 크기 제한 (바이트): <– 0
로컬 주소 확장 문자: <– +
사용할 인터넷 프로토콜: <– 모두

다음으로, 다음을 수행하십시오:

postconf -e ‘smtpd_sasl_local_domain =’
postconf -e ‘smtpd_sasl_auth_enable = yes’
postconf -e ‘smtpd_sasl_security_options = noanonymous’
postconf -e ‘broken_sasl_auth_clients = yes’
postconf -e ‘smtpd_sasl_authenticated_header = yes’
postconf -e ‘smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination’
postconf -e ‘inet_interfaces = all’
echo ‘pwcheck_method: saslauthd’ >> /etc/postfix/sasl/smtpd.conf
echo ‘mech_list: plain login’ >> /etc/postfix/sasl/smtpd.conf

그 후 TLS용 인증서를 생성합니다:

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024

chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr

openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted

mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

다음으로 TLS를 위해 Postfix를 구성합니다 (myhostname에 올바른 호스트 이름을 사용하고 있는지 확인하십시오):

postconf -e 'myhostname = server1.example.com'

postconf -e ‘smtpd_tls_auth_only = no’
postconf -e ‘smtp_use_tls = yes’
postconf -e ‘smtpd_use_tls = yes’
postconf -e ‘smtp_tls_note_starttls_offer = yes’
postconf -e ‘smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key’
postconf -e ‘smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt’
postconf -e ‘smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem’
postconf -e ‘smtpd_tls_loglevel = 1’
postconf -e ‘smtpd_tls_received_header = yes’
postconf -e ‘smtpd_tls_session_cache_timeout = 3600s’
postconf -e ‘tls_random_source = dev:/dev/urandom’

이제 /etc/postfix/main.cf 파일은 다음과 같아야 합니다:

cat /etc/postfix/main.cf

| # See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = no # TLS parameters smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_use_tls = yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. myhostname = server1.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = server1.example.com, localhost.example.com, localhost.localdomain, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_tls_auth_only = no smtp_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom |

인증은 saslauthd에 의해 수행됩니다. 제대로 작동하도록 몇 가지를 변경해야 합니다. Postfix가 /var/spool/postfix에서 chroot로 실행되기 때문에 다음을 수행해야 합니다:

mkdir -p /var/spool/postfix/var/run/saslauthd

이제 /etc/default/saslauthd를 편집하여 saslauthd를 활성화해야 합니다. START를 yes로 설정하고 OPTIONS=”-c -m /var/run/saslauthd” 줄을 OPTIONS=”-c -m /var/spool/postfix/var/run/saslauthd -r”로 변경하십시오:

vi /etc/default/saslauthd

| # # Settings for saslauthd daemon # Please read /usr/share/doc/sasl2-bin/README.Debian for details. # # Should saslauthd run automatically on startup? (default: no) START=yes # Description of this saslauthd instance. Recommended. # (suggestion: SASL Authentication Daemon) DESC="SASL Authentication Daemon" # Short name of this saslauthd instance. Strongly recommended. # (suggestion: saslauthd) NAME="saslauthd" # Which authentication mechanisms should saslauthd use? (default: pam) # # Available options in this Debian package: # getpwent -- use the getpwent() library function # kerberos5 -- use Kerberos 5 # pam -- use PAM # rimap -- use a remote IMAP server # shadow -- use the local shadow password file # sasldb -- use the local sasldb database file # ldap -- use LDAP (configuration is in /etc/saslauthd.conf) # # Only one option may be used at a time. See the saslauthd man page # for more information. # # Example: MECHANISMS="pam" MECHANISMS="pam" # Additional options for this mechanism. (default: none) # See the saslauthd man page for information about mech-specific options. MECH_OPTIONS="" # How many saslauthd processes should we run? (default: 5) # A value of 0 will fork a new process for each connection. THREADS=5 # Other options (default: -c -m /var/run/saslauthd) # Note: You MUST specify the -m option or saslauthd won't run! # # WARNING: DO NOT SPECIFY THE -d OPTION. # The -d option will cause saslauthd to run in the foreground instead of as # a daemon. This will PREVENT YOUR SYSTEM FROM BOOTING PROPERLY. If you wish # to run saslauthd in debug mode, please run it by hand to be safe. # # See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information. # See the saslauthd man page and the output of 'saslauthd -h' for general # information about these options. # # Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd" #OPTIONS="-c -m /var/run/saslauthd" OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" |

다음으로 postfix 사용자를 sasl 그룹에 추가합니다 (이렇게 하면 Postfix가 saslauthd에 접근할 수 있는 권한을 갖게 됩니다):

adduser postfix sasl

이제 Postfix를 재시작하고 saslauthd를 시작하십시오:

/etc/init.d/postfix restart
/etc/init.d/saslauthd start

SMTP-AUTH 및 TLS가 제대로 작동하는지 확인하려면 다음 명령을 실행하십시오:

telnet localhost 25

Postfix 메일 서버에 연결한 후 다음을 입력하십시오:

ehlo localhost

다음과 같은 줄이 표시되면

250-STARTTLS

250-AUTH PLAIN LOGIN

모든 것이 정상입니다.

내 시스템의 출력은 다음과 같습니다:

root@server1:/etc/postfix/ssl# telnet localhost 25
Trying ::1…
Connected to localhost.localdomain.
Escape character is ‘^]’.
220 server1.example.com ESMTP Postfix (Ubuntu)
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
root@server1:/etc/postfix/ssl#

quit

를 입력하여 시스템의 셸로 돌아갑니다.

16 Courier-IMAP/Courier-POP3

다음 명령을 실행하여 Courier-IMAP/Courier-IMAP-SSL (IMAPs 포트 993용) 및 Courier-POP3/Courier-POP3-SSL (POP3s 포트 995용)을 설치하십시오:

aptitude install courier-authdaemon courier-base courier-imap courier-imap-ssl courier-pop courier-pop-ssl courier-ssl gamin libgamin0 libglib2.0-0 

두 가지 질문이 표시됩니다:

웹 기반 관리용 디렉토리 생성? <– 아니요
SSL 인증서 필요 <– 확인

설치 중에 IMAP-SSL 및 POP3-SSL용 SSL 인증서가 localhost라는 호스트 이름으로 생성됩니다. 이를 올바른 호스트 이름 (이 튜토리얼에서는 server1.example.com)으로 변경하려면 인증서를 삭제하십시오…

cd /etc/courier
rm -f /etc/courier/imapd.pem
rm -f /etc/courier/pop3d.pem

… 다음 두 파일을 수정하십시오; CN=localhost를 CN=server1.example.com으로 바꾸십시오 (필요한 경우 다른 값도 수정할 수 있습니다):

vi /etc/courier/imapd.cnf

| [...] CN=server1.example.com [...] |

vi /etc/courier/pop3d.cnf

| [...] CN=server1.example.com [...] |

그런 다음 인증서를 다시 생성하십시오…

mkimapdcert
mkpop3dcert

… 그리고 Courier-IMAP-SSL 및 Courier-POP3-SSL을 재시작하십시오:

/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop-ssl restart

ISPConfig를 사용하지 않으려면 Postfix를 사용자의 Maildir*에 이메일을 배달하도록 구성하십시오:

postconf -e ‘home_mailbox = Maildir/‘
postconf -e ‘mailbox_command =’
/etc/init.d/postfix restart

*참고: ISPConfig를 시스템에서 사용할 계획이라면 이 작업을 수행할 필요가 없습니다. ISPConfig는 procmail 레시피를 사용하여 필요한 구성을 수행합니다. 그러나 ISPConfig 웹 인터페이스의 관리 -> 서버 -> 설정 -> 이메일에서 Maildir을 활성화해야 합니다.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.