LINUX.ORG.RU
решено ФорумAdmin

Postfix relay to Exchange аутентификация

 , ,


0

1

Подскажите, пожалуйста, в какую сторону двигаться или что мне нужно сделать, чтобы заработало.

Имеется сервер CentOS 6.6 с Postfix 2.6.6-6. Мне нужно, чтобы для определенного домена (например для example.com) почта шла через определенный SMTP-сервер (mail.example.com, Microsoft Exchange).

На MS Exchange настроена аутентификация: 250-AUTH GSSAPI NTLM

Мне дали login и password, заведенные на Exchange. С ними надо аутентифицироваться на mail.example.com:587

Использую Cyrus SASL. Конфигурация Postfix (mail.test.ru):

cat main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.test.ru
mydomain = sberinsur.ru
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 10.0.54.0/24, 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_sender_login_maps = hash:/etc/postfix/controlled_envelope_senders
smtpd_recipient_restrictions =
   permit_mynetworks,
   check_relay_domains,
   reject
   
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

broken_sasl_auth_clients = yes

readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
transport_maps = hash:/etc/postfix/transport

Логин и пароль записал:

vi /etc/postfix/sasl_passwd
mail.example.ru	info:P@ssword

postmap /etc/postfix/sasl_passwd

Настраиваю перенаправление почты, предназначенной для example.ru, на SMTP сервер с MS Exchange:

vi transport
example.ru	smtp:mail.example.ru:587

postmap transport

Теперь настраиваем gssapi: Убедимся, что он установлен:

rpm -qa | grep cyrus
cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-ntlm-2.1.23-15.el6_6.2.x86_64

ll /usr/lib64/sasl2/libgssapiv2.so*
lrwxrwxrwx 1 root root    21 Aug 15 16:57 /usr/lib64/sasl2/libgssapiv2.so -> libgssapiv2.so.2.0.23
lrwxrwxrwx 1 root root    21 Aug 15 16:57 /usr/lib64/sasl2/libgssapiv2.so.2 -> libgssapiv2.so.2.0.23
-rwxr-xr-x 1 root root 31256 Mar 25  2015 /usr/lib64/sasl2/libgssapiv2.so.2.0.23

cat /etc/sasl2/smtpd.conf 
pwcheck_method: saslauthd
mech_list: gssapi ntlm plain login
cat /etc/sysconfig/saslauthd 
SOCKETDIR=/var/run/saslauthd
MECH=pam
FLAGS=

Пытаюсь отправить письмо с сервера Postfix на существующий email в домене example.ru:

echo "TEST EMAIL" | mailx -v -r "test1@example.ru" -s "Test email" -S smtp="127.0.0.1:25"  support@example.ru

Connecting to 127.0.0.1 . . . connected.
220 mail.test.ru ESMTP Postfix
>>> HELO mail.test.ru
250 mail.test.ru
>>> MAIL FROM:<test1@example.ru
250 2.1.0 Ok
>>> RCPT TO:<support@example.ru
250 2.1.5 Ok
>>> DATA
354 End data with <CR><LF>.<CR><LF>
>>> .
250 2.0.0 Ok: queued as 2006A280594
>>> QUIT
221 2.0.0 Bye

Письмо встало в очередь:

postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
F2B51280594      574 Mon Aug 15 18:39:42  test1@test.ru
(SASL authentication failed; cannot authenticate to server mail.example.ru[123.123.123.123]: generic failure)
                                         support@example.ru
В логах maillog:
Aug 15 18:49:18 mail.test.ru postfix/smtp[63493]: warning: SASL authentication failure: GSSAPI Error: Unspecified GSS failure.  Minor code may provide more information (Credentials cache file '/tmp/krb5cc_89' not found)
Aug 15 18:49:18 mail.test.ru postfix/smtp[63493]: F2B51280594: to=<support@example.ru>, relay=mail.example.ru[123.123.123.123]:587, delay=576, delays=575/0.02/0.08/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server mail.example.ru[123.123.123.123]: generic failure)

Как мне правильно настроить аутентификацию Postfix по Kerberos на Exchange? Смущает стркоа:

Credentials cache file '/tmp/krb5cc_89' not found

Не совсем ясно как настраивать. И готовых примеров с GSSAPI мало в интернете.



Последнее исправление: SoHm (всего исправлений: 2)

postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
F2B51280594      574 Mon Aug 15 18:39:42  support@example.ru
(SASL authentication failed; cannot authenticate to server mail.example.ru[123.123.123.123]: generic failure)
                                         support@example.ru

Отправитель и получатель «support@example.ru», а учетная запись на «test1@example.ru»?

# postcat -vq F2B51280594
anonymous
()
Ответ на: комментарий от anonymous

Прошу прощения, забыл заменить. Исправил в начальном посте как это и должно было быть.

[root@mail.test.ru postfix]# postcat -vq 2006A280594
postcat: dict_eval: const  mail
postcat: dict_eval: const  all
postcat: dict_eval: const  
postcat: dict_eval: const  
postcat: dict_eval: const  
postcat: name_mask: all
postcat: dict_eval: const  mail.test.ru
postcat: dict_eval: const  test.ru
postcat: dict_eval: const  Postfix
postcat: dict_eval: expand ${multi_instance_name:postfix}${multi_instance_name?$multi_instance_name} -> postfix
postcat: dict_eval: const  postfix
postcat: dict_eval: const  postdrop
postcat: dict_eval: expand $myhostname, localhost.$mydomain, localhost -> mail.test.ru, localhost.test.ru, localhost
postcat: dict_eval: expand $myhostname -> mail.test.ru
postcat: dict_eval: const  
postcat: dict_eval: const  /usr/libexec/postfix
postcat: dict_eval: const  /var/lib/postfix
postcat: dict_eval: const  /usr/sbin
postcat: dict_eval: const  /var/spool/postfix
postcat: dict_eval: const  pid
postcat: dict_eval: const  all
postcat: dict_eval: const  
postcat: dict_eval: const  double-bounce
postcat: dict_eval: const  nobody
postcat: dict_eval: const  hash:/etc/aliases
postcat: dict_eval: const  20100319
postcat: dict_eval: const  2.6.6
postcat: dict_eval: const  hash
postcat: dict_eval: const  deferred, defer
postcat: dict_eval: const  
postcat: dict_eval: expand $mydestination -> mail.test.ru, mail.test.ru, localhost
postcat: dict_eval: expand $relay_domains -> mail.test.ru, mail.test.ru, localhost
postcat: dict_eval: const  TZ MAIL_CONFIG LANG
postcat: dict_eval: const  MAIL_CONFIG MAIL_DEBUG MAIL_LOGTAG TZ XAUTHORITY DISPLAY LANG=C
postcat: dict_eval: const  subnet
postcat: dict_eval: const  
postcat: dict_eval: const  +=
postcat: dict_eval: const  -=+
postcat: dict_eval: const  debug_peer_list,fast_flush_domains,mynetworks,permit_mx_backup_networks,qmqpd_authorized_clients,relay_domains,smtpd_access_maps
postcat: dict_eval: const  
postcat: dict_eval: const  bounce
postcat: dict_eval: const  cleanup
postcat: dict_eval: const  defer
postcat: dict_eval: const  pickup
postcat: dict_eval: const  qmgr
postcat: dict_eval: const  rewrite
postcat: dict_eval: const  showq
postcat: dict_eval: const  error
postcat: dict_eval: const  flush
postcat: dict_eval: const  verify
postcat: dict_eval: const  trace
postcat: dict_eval: const  proxymap
postcat: dict_eval: const  proxywrite
postcat: dict_eval: const  
postcat: dict_eval: const  
postcat: dict_eval: const  2
postcat: dict_eval: const  100s
postcat: dict_eval: const  100s
postcat: dict_eval: const  100s
postcat: dict_eval: const  100s
postcat: dict_eval: const  3600s
postcat: dict_eval: const  3600s
postcat: dict_eval: const  5s
postcat: dict_eval: const  5s
postcat: dict_eval: const  1000s
postcat: dict_eval: const  1000s
postcat: dict_eval: const  10s
postcat: dict_eval: const  10s
postcat: dict_eval: const  1s
postcat: dict_eval: const  1s
postcat: dict_eval: const  1s
postcat: dict_eval: const  1s
postcat: dict_eval: const  500s
postcat: dict_eval: const  500s
postcat: dict_eval: const  18000s
postcat: dict_eval: const  18000s
postcat: dict_eval: const  1s
postcat: dict_eval: const  1s
postcat: dict_eval: const  10.0.54.0/24, 127.0.0.0/8
postcat: inet_addr_local: configured 2 IPv4 addresses
postcat: inet_addr_local: configured 2 IPv6 addresses
*** ENVELOPE RECORDS active/2006A280594 ***
message_size:             574             599               1               0             574
message_arrival_time: Mon Aug 15 21:45:44 2016
create_time: Mon Aug 15 21:45:44 2016
named_attribute: rewrite_context=local
sender: test1@example.ru
named_attribute: log_client_name=localhost
named_attribute: log_client_address=127.0.0.1
named_attribute: log_client_port=58146
named_attribute: log_message_origin=localhost[127.0.0.1]
named_attribute: log_helo_name=mail.test.ru
named_attribute: log_protocol_name=SMTP
named_attribute: client_name=localhost
named_attribute: reverse_client_name=localhost
named_attribute: client_address=127.0.0.1
named_attribute: client_port=58146
named_attribute: helo_name=mail.test.ru
named_attribute: protocol_name=SMTP
named_attribute: client_address_type=2
named_attribute: dsn_orig_rcpt=rfc822;support@example.ru
original_recipient: support@example.ru
recipient: support@example.ru
*** MESSAGE CONTENTS active/2006A280594 ***
regular_text: Received: from mail.test.ru (localhost [127.0.0.1])
regular_text: 	by mail.test.ru (Postfix) with SMTP id 2006A280594
regular_text: 	for <support@example.ru>; Mon, 15 Aug 2016 21:45:44 +0300 (MSK)
regular_text: Date: Mon, 15 Aug 2016 21:45:44 +0300
regular_text: From: test1@example.ru
regular_text: To: support@example.ru
regular_text: Subject: Test email
regular_text: Message-ID: <57b20dd8.beErysenW5XXiWzW%test1@example.ru>
regular_text: User-Agent: Heirloom mailx 12.4 7/29/08
regular_text: MIME-Version: 1.0
regular_text: Content-Type: text/plain; charset=us-ascii
regular_text: Content-Transfer-Encoding: 7bit
regular_text: 
regular_text: This message sent from MAILX utility from Linux server mail.test.ru (postfix)
*** HEADER EXTRACTED active/2006A280594 ***
*** MESSAGE FILE END active/2006A280594 ***
SoHm
() автор топика

Мне дали login и password, заведенные на Exchange.

От учетной записи test1@example.ru?

С ними надо аутентифицироваться на mail.example.com:587

Тут тоже ошибка?

anonymous
()
Ответ на: комментарий от anonymous

Как я понял из мануалов, для аутентификации логин и пароль записываются в файл, допустим sasl_passwd

cat /etc/postfix/sasl_passwd
mail.example.ru	info:P@ssword

и он указывается в конфиге main.cf

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

В первом посте это написано.

SoHm
() автор топика
Ответ на: комментарий от SoHm

Допустим, что учетная запись «info:P@ssword» от почтового ящика «info@example.ru». Тогда вам необходимо создать следующие карты:

smtpd_sender_login_maps = hash:/etc/postfix/controlled_envelope_senders
info@example.ru   user@test.ru
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
mail.example.ru   info@example.ru:P@ssword
# или
mail.example.ru   info:P@ssword
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_maps
info@example.ru   [mail.example.ru]:587

Создайте локальный почтовый ящик «user@test.ru» и отправляйте с него сообщения.

anonymous
()
Ответ на: комментарий от anonymous

Спасибо за то, что подсказали про данную возможность.

Кстати, проблема решилась, но проблема была на другой стороне. Администратор на Exchange запретил отправлять с других почтовых ящиков, кроме залогиненного. Как только он разрешил отправлять для данного username login от имени дургих/требуемых username - всё заработало.

Благодарю всех отозвавшихся по моей проблеме!

SoHm
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.