서버 설정 · 4 min read · Oct 26, 2025

완벽한 설정 - Debian Etch (Debian 4.0) - 페이지 5

11 Postfix With SMTP-AUTH And TLS

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

apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail

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

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

그런 다음 실행합니다:

dpkg-reconfigure postfix

다시 몇 가지 질문을 받게 됩니다:

일반 구성 유형? <– 인터넷 사이트
루트의 메일은 어디로 가야 합니까? <– [빈칸]
메일 이름? <– server1.example.com
메일을 수신할 다른 목적지는 무엇입니까? (없으면 빈칸) <– server1.example.com, localhost.example.com, localhost.localdomain, localhost
메일 큐에서 동기식 업데이트 강제 적용? <– 아니오
로컬 네트워크? <– 127.0.0.0/8
로컬 배달에 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_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를 구성합니다:

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’
postconf -e ‘myhostname = server1.example.com’

파일 /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 (Debian/GNU) 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 # 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:${queue_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${queue_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 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_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 |

Postfix를 재시작합니다:

/etc/init.d/postfix restart

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

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

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

vi /etc/default/saslauthd

| # # Settings for saslauthd daemon # # Should saslauthd run automatically on startup? (default: no) START=yes # 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) # See the saslauthd man page for information about these options. # # Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd" # Note: See /usr/share/doc/sasl2-bin/README.Debian OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" |

이제 saslauthd를 시작합니다:

/etc/init.d/saslauthd start

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

telnet localhost 25

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

ehlo localhost

다음 줄이 보이면

250-STARTTLS

250-AUTH PLAIN LOGIN

모든 것이 정상입니다.

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

server1:/etc/postfix/ssl# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.localdomain.
Escape character is ‘^]’.
220 server1.example.com ESMTP Postfix (Debian/GNU)
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.

quit

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

12 Courier-IMAP/Courier-POP3

다음 명령을 실행하여 Courier-IMAP/Courier-IMAP-SSL(포트 993의 IMAP용) 및 Courier-POP3/Courier-POP3-SSL(포트 995의 POP3용)을 설치합니다:

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

두 가지 질문을 받게 됩니다:

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

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

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

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