POSTFIX의 SASL 설정에 관하여 질문드립니다.
지난 번에 POSTFIX의 설정에 관해서 질문을 드렸는데...제가 한 SMTP 서버 설정에 문제가 있나봐요.
바쁜 와중에 나름 시간을 쪼개서 해봤는데 부족하기 짝이 없습니다.
외부에서 POSTFIX를 사용할 때, 인증조차 거치지 않는다는 것이 문제였습니다.
그래서 SASL을 활용하여 간단한 인증 절차를 거치려고 했습니다. 결론은...지금 telnet을 이용한 테스트가 되지 않고요. postfix설정이 잘못 된것 같습니다.
SASL을 시도하기 전까지는 모든 것이 잘 돌아갔고요..SASL 관련 글을 참고하여 건들고 나서 안됩니다.
그런데 어디가 잘못된 것인줄을 몰라서 이렇게 의견을 여쭙습니다..,
미리 밝혀두자면, 저의 리눅스 운영체제는 UBUNTU 12.1O, POSTFIX는 2.9.3입니다.
참고한 홈페이지는 https://help.ubuntu.com/community/Postfix 입니다. 진짜 하라는대로 했습니다.
먼저 저의 /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/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/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 = localhost.localdomain, localhost, server1.example.com # 여기서도 역시, 메일을 로컬로 수신하는 도메인명을 다 넣었습니다.
relayhost =
mynetworks = 127.0.0.0/8 # 여기서도 이용하는 IP의 네트워크 CIDR 표기를 하나 더 넣었습니다.
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
mailbox_command =
inet_protocols = all
luser_relay = user1@server1.example.com
local_recipient_maps =
virtual_alias_domains = server1.example.com
virtual_alias_maps = hash:/etc/postfix/virtual
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
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_auth_only = no
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
##############################################################################################################################################################################
main.cf의 내용은 위와 같습니다. 그 이외에는 참고한 홈페이지의 지시와 같이..
- /etc/postfix/sasl/smtpd.conf에는
pwcheck_method: saslauthd
mech_list: plain login
의 내용을 넣었습니다.
- smtpd.ket파일을 만들어서,
openssl req -new -key smtpd.key -x509 -days 3650 -out smtpd.crt
을 했더니 지역과 이름 그리고 메일등의 정보를 입력하라고 하기에 입력하였고,
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
을 입력후에는, Enter PEM pass phrase : 라는 문구가 나와 "whatever"라고 하였습니다. 그 이후의 지역,소속,이름,메일등의 정보는 위와 같이 하였습니다.
- 그 이후 아래와 같이 이동시켰습니다.
mv smtpd.key /etc/ssl/private/
mv smtpd.crt /etc/ssl/certs/
mv smtpd.crt /etc/ssl/certs/
mv cacert.pem /etc/ssl/certs/
- dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd 라는 명령어는
dpkg-statoverride: warning: an override for '/var/spool/postfix/var/run/saslauthd' already exists, but --force specified so will be ignored 라는 오류메시지가 떴습니다.
- 또한, /etc/postfix/master.cf의
smtp inet n - - - - smtpd 라인은
smtp inet n - n - - smtpd 와 같이 수정하였습니다.
- 마지막으로,
/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
PWDIR="/var/spool/postfix/var/run/saslauthd"
PARAMS="-m ${PWDIR}"
PIDFILE="${PWDIR}/saslauthd.pid"
# 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 shadow"
# 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 chroot Postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Example for non-chroot Postfix users: "-c -m /var/run/saslauthd"
#
# To know if your Postfix is running chroot, check /etc/postfix/master.cf.
# If it has the line "smtp inet n - y - - smtpd" or "smtp inet n - - - - smtpd"
# then your Postfix is running in a chroot.
# If it has the line "smtp inet n - n - - smtpd" then your Postfix is NOT
# running in a chroot.
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
###############################################################################################################################################################################
- 하라는 대로 했는데 안 됩니다. telnet 테스트를 하는데...
telnet localhost 25 를 하면
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
까지밖에 안 나옵니다. 220 server1.example.com ESMTP Postfix (Ubuntu) 라는 문구가 뜨지 않네요...
mail to, quit 등등 여러 명령어 쳐도 안 먹히고요..여기서 도무지 해답이 안 보입니다..
제가 했던 과정을 어느정도 적다보니 길어졌는데, 어느 부분이 잘못 되었는지 감이 없어서 모두 적었습니다..
바쁘시겠지만, 이곳은 실무자분들이 많은 곳이라 저에게 도움을 주실 수 있는 분들이 많을거라 생각하여 글을 남깁니다.
도움주시면 정말 감사하겠습니다.
댓글 달기