2019年2月24日日曜日

outlook + postfix/dovecotの研究(3つ以上のメールアカウントを追加後にメールが送れない件)

outlookで複数のアカウント追加後にメール送信ができなかったことについての
レポート。

◻️出来ること
outlookでメールアカウントの追加は、最大2個以上増やさない方が良い。

◻️出来ないこと
新規で、3個目に追加したメールアカウントについては、メールの送信が出来ないことが判明した。
(1つ目、2つ目に追加したメールアカウントについては、普通にメールの送受信が可能)



メールを(例:test1)に送信後、何故か送信済みにトレイに移行していない状態。




◻️メールを送信できないので、/var/log/maillogを見ると、送信できないメッセージが記載されていることがわかる。





[memo]
◻️その他、outlookでの検証結果

①test1
②test2
③test5   <----新規追加

上記、②③を削除して、再度新規で2つ目のメールアカウントを追加した場合
2つ目のメールアカウントも送信できない状態になるので
そうなった場合、一旦dovecotのサービスを再起動すること!!

postfix(ゾンビプロセスについて)

サービスを確認した時に、以下の邪魔なメッセージが出ている。
どうもゾンビプロセスのような感じ。
ということで、対象のプロセスをまずは確認する。

[root@digihide named]# systemctl status dovecot
dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-02-24 09:44:10 JST; 1s ago
     Docs: man:dovecot(1)
           http://wiki2.dovecot.org/
  Process: 3893 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
  Process: 3903 ExecStart=/usr/sbin/dovecot (code=exited, status=0/SUCCESS)
  Process: 3897 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited, status=0/SUCCESS)
 Main PID: 3905 (dovecot)
   CGroup: /system.slice/dovecot.service
           ├─3905 /usr/sbin/dovecot
           ├─3906 dovecot/anvil
           ├─3907 dovecot/log
           └─3909 dovecot/config

Feb 24 09:44:10 digihide.local systemd[1]: Stopped Dovecot IMAP/POP3 email server.
Feb 24 09:44:10 digihide.local systemd[1]: Starting Dovecot IMAP/POP3 email server...
Feb 24 09:44:10 digihide.local systemd[1]: PID file /var/run/dovecot/master.pid not readable (yet?) after start.
Feb 24 09:44:10 digihide.local dovecot[3905]: master: Dovecot v2.2.36 (1f10bfa63) starting up for imap, pop3 (core dumps disabled)
Feb 24 09:44:10 digihide.local systemd[1]: Started Dovecot IMAP/POP3 email server.

===================================

◻️謎の以下のプロセスを消すことにする。
[root@digihide named]# ps `cat /var/run/dovecot/master.pid`
  PID TTY      STAT   TIME COMMAND
 3905 ?        Ss     0:00 /usr/sbin/dovecot


◻️対象のプロセスを消す。
[root@digihide named]# kill -9 3905

◻️プロセスの中身を確認する。
[root@digihide named]# ps `cat /var/run/dovecot/master.pid`


◻️消えていることを確認する。
cat: /var/run/dovecot/master.pid: No such file or directory
  PID TTY          TIME CMD
 3429 pts/0    00:00:00 bash
 3920 pts/0    00:00:00 ps


◻️念の為、dovecotのサービスを確認する。先ほどの内容が消えていることが分かる。
[root@digihide named]# systemctl restart dovecot
[root@digihide named]# systemctl status dovecot
dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-02-24 09:46:27 JST; 3s ago
     Docs: man:dovecot(1)
           http://wiki2.dovecot.org/
  Process: 3915 ExecStop=/usr/bin/doveadm stop (code=exited, status=75)
  Process: 3933 ExecStart=/usr/sbin/dovecot (code=exited, status=0/SUCCESS)
  Process: 3927 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited, status=0/SUCCESS)
 Main PID: 3935 (dovecot)
   CGroup: /system.slice/dovecot.service
           ├─3935 /usr/sbin/dovecot
           ├─3936 dovecot/anvil
           ├─3937 dovecot/log
           └─3939 dovecot/config

Feb 24 09:46:27 digihide.local systemd[1]: Starting Dovecot IMAP/POP3 email server...
Feb 24 09:46:27 digihide.local systemd[1]: PID file /var/run/dovecot/master.pid not readable (yet?) after start.
Feb 24 09:46:27 digihide.local dovecot[3935]: master: Dovecot v2.2.36 (1f10bfa63) starting up for imap, pop3 (core dumps disabled)

Feb 24 09:46:27 digihide.local systemd[1]: Started Dovecot IMAP/POP3 email server.

outlook + postfix/dovecot(アカウント追加の研究)

◻️windows環境:
①windows 10 pro
バージョン:1809
OSビルド:17763.107

②メール
バージョン:16006.11029.20108.0

③その他
windows firewallをoffにしている。
SEPは入れてない。


outlookで新規アカウントを登録した場合、以下のような
証明書のエラーが出てしまう。


<検証画像>


<拡大画像1>


<拡大画像2>



ちなみに、コントロールパネル > インタネットオプション > コンテンツ >証明書から
作成済みの証明書をインストールを行って、outlookでメールアカウントの追加を行っても
証明書のエラーは出るようだ。



[memo]
①test1 ->test2間で普通に送受信ができることを確認する。
②メールアカウント追加直後にtest1 ->test2間でメールの送受信は直ぐにできなかった。
③メールアカウントを新規で追加を行うたびに、証明書の警告が出る。
  ->認証ボタン?を押すと、その後、証明書の警告は出ていない。

2019年2月23日土曜日

作成した証明書の確認

opensslコマンドにて整合性を確認することが可能
秘密鍵の内容を確認 
# openssl rsa -text -noout -in [秘密鍵]
CSRの内容を確認 
# openssl req -text -noout -in [CSR] 
証明書の内容を確認 
# openssl x509 -text -noout -in [証明書]
# openssl s_client -connect mail.digihide.local:465

2019年2月19日火曜日

postfix(送信規制)

◻️以下のpostfixの追記を行う。

======/etc/postfix/main.cf=========================
# local send mail only
check_local_only = check_recipient_access hash:/etc/postfix/local_domains,reject
check_sender_restriction = check_sender_access hash:/etc/postfix/restricted_senders
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/restricted_senders
smtpd_restriction_classes = local_only
local_only = check_recipient_access hash:/etc/postfix/local_domains,reject
============================================

vi /etc/postfix/restricted_senders
=======restricted_senders=======
test1@digihide.local  local_only
============================
/etc/postfix/local_domains
=====local_domains======
digihide.local OK
======================
◻️MAPを更新する。

# postmap /etc/postfix/restricted_senders
# postmap /etc/postfix/local_domains 
◻️postfixのサービスを再起動を行う
systemctl restart posrfix


◻️以下、編集する。
/etc/postfix/master.cf
========================================
smtp      inet  n       -       n       -       -        smtpd 
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
#submission inet n       -       n       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd 
#  -o syslog_name=postfix/smtps
   -o smtpd_tls_wrappermode=yes
   -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
   -o smtpd_restriction_classes=local_only
   -o local_only=${check_local_only}
   -o smtpd_sender_restrictions=${check_sender_restriction}
   -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
==================================================

2019年2月17日日曜日

postfix設定メモ

以下、不要かもリスト;


◻️/etc/postfix/main.cf

###########  add settings  ##################
#local_recipient_maps =
#luser_relay = unknown_user@localhost
#disable_vrfy_command = yes

# MailBox
mailbox_size_limit = 204800000

#smtpd_client_restrictions =
#    check_client_access hash:/etc/postfix/access
#    reject_rbl_client zen.spamhaus.org
#    reject_non_fqdn_sender
#    reject_unknown_sender_domain
#smtpd_sender_restrictions =
#        reject_rhsbl_sender zen.spamhaus.org
#        reject_unknown_sender_domain

########## SMTP-Auth ##########

# Dovecot SASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
broken_sasl_auth_clients = yes


# SASL Authentication
smtpd_sasl_auth_enable = yes
#smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd  <--リレー送信用の設定なので、今回は不要
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_sasl_auth_enable = yes
smtp_sasl_tls_security_options = noanonymous


########## TLS/SSL ##########
smtpd_use_tls = yes
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/pki/tls/device.crt
smtpd_tls_key_file = /etc/pki/tls/device.key
smtpd_tls_CAfile = /etc/pki/tls/rootCA.pem
tls_random_source = dev:/dev/urandom

smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_sasl_auth_enable = yes

#smtpd_recipient_restrictions =
#    permit_mynetworks
#    permit_sasl_authenticated

#    reject_unauth_destination

2019年2月16日土曜日

メール送受信サービスの接続許可設定(firewalld)

◻️メール送受信サービスの接続許可設定

public”ゾーンの接続許可サービスにSMTPSMTP-SubmissionPOP3IMAP4の4サービスを追加します。
追加はfirewall-cmdで以下のように行います。


# firewall-cmd --zone=public --add-service={smtp,smtp-submission,pop3,imap} --permanent
success

”success”と表示されれば追加は完了です。


◻️設定を反映するためにファイアウォールの設定をリロードします。

# firewall-cmd --reload
success

postfix設定ファイル確認コマンド

Postfixには設定ファイルの誤りをチェックするためのコマンド”postfix check”が用意されています。このコマンドで設定ファイルのチェックも行っておきます。

2019年2月11日月曜日

GitHub ssh key登録


cd ~/.ssh

keyの作成を行う。
 ->パスワードは無にした。
ssh-keygen-trsa


以下で、作成された、公開鍵を GitHubに登録する。


white medium-small square️GitHub ssh key登録

1)以下のGitHubのssh keyの登録を行う。

2)New SSH Keyを押す


3)ローカル内で、鍵の中身のクリップボードへのコピーを行う。
①Titele :  適当に入力
②Key    : 公開鍵をペーストする。
 
4)Add SSH Keyを押す。


以下のファイルの編集を行う。

vi ~/.ssh/config
=============================
Host github
user git
Hostname github.com
Port 22
IdentityFile ~/.ssh/(秘密鍵のファイル名)
=============================


white medium-small squaregit push origin master実施後に、以下が表示されたら
  git remote rm origin
  git remote add origin git@github.com:digihide/test888.git
  git push-uorigin master

2019年2月10日日曜日

postfix/dovecotの証明書の実験

以下、作成済みの証明書の中身をグチャグチャに変更した状態で
メーラーを接続すると、証明書のエラーが出てるので
postfix/dovecotサーバーとメーラー間で認識出来ていることが分かる

=======各種証明書==================
smtpd_tls_cert_file = /etc/pki/tls/device.crt
smtpd_tls_key_file = /etc/pki/tls/device.key
smtpd_tls_CAfile = /etc/pki/tls/rootCA.pe


◻️環境
機種:imac
メーラー:mail.app
server:centos7.x
os:postfix/dovecot/bindなど

メールアカウントが追加できない場合の対策について

◻️メールアカウントの追加でエラーが出た場合、以下の方法で権限の付与を行うこと!!

Feb 10 09:30:04 digiweb dovecot: pop3-login: Login: user=<digi01>, method=PLAIN, rip=192.168.1.201, lip=192.168.1.224, mpid=1436, TLS, session=<ps8fS3+BKQDAqAHJ>
Feb 10 09:30:04 digiweb dovecot: pop3(digi01): Error: stat(/home/digi01/Maildir/tmp) failed: Permission denied (euid=1001(digi01) egid=1001(digi01) missing +x perm: /home/digi01/Maildir, dir owned by 0:0 mode=0700)
Feb 10 09:30:04 digiweb dovecot: pop3(digi01): Error: Couldn't open INBOX: Internal error occurred. Refer to server log for more information. [2019-02-10 09:30:04]


◻️以下の権限付与を行うこと!
chown -R ユーザ名:ユーザ名 /home/ユーザ名

例)
chown -R digi01:digi01 /home/digi01



[root@digiweb home]# ls -la

drwx------   3 digi01     digi01      77 Feb 10 00:26 digi01
drwx------.  3 test-user1 test-user1  77 Sep 25 15:44 test-user1



参考ページ:

http://kajuhome.com/patio_thread/2080.shtml

2019年2月9日土曜日

ログのデバック出力 postfix/dovecot編

◻️dovecotのデバックログの出し方について

以下の内容を末端に追加するだけ

/etc/dovecot/dovecot.conf
========dovecot.conf========
auth_verbose = yes
auth_debug = yes
===========================


◻️postfixのデバックログの出力方法について

以下に -v を追加するだけ

=======/etc/postfix/main.cf====================================
#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd -v
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
#submission inet n       -       n       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd -v
#  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
===============================================================

SASL PLAIN authentication failed

/var/log/maillogに以下のエラーが出ている場合の対策

<エラー表示>
SASL PLAIN authentication failed


◻️以下の内容を追記すること

vi /etc/dovecot/conf.d/auth-system.conf.ext
================auth-system.conf.ext=======================
passdb {
  driver = pam
  # [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
  # [cache_key=<key>] [<service name>]
  #args = dovecot
  override_fields = allow_nets=127.0.0.0/8,::1/128,fe80::/64,192.168.1.0/24
  # 上記を加筆
}
========================================================


◻️以下の内容を確認する

/etc/postfix/10-auth.confの以下の内容通りになっているか確認する
===========10-auth-conf====================
# <doc/wiki/UserDatabase.txt>

#!include auth-deny.conf.ext
#!include auth-master.conf.ext

!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

========================================




上記の設定の状態であれば、以下のような、認証表示になっていると思われる。

=============/var/log/maillog=============================
Dec 15 05:10:17 node-1 dovecot: auth: Debug: pam(user1,192.168.1.201): allow_nets: Matching for network 127.0.0.0/8
Dec 15 05:10:17 node-1 dovecot: auth: Debug: pam(user1,192.168.1.201): allow_nets: Matching for network ::1/128
Dec 15 05:10:17 node-1 dovecot: auth: Debug: pam(user1,192.168.1.201): allow_nets: Matching for network fe80::/64
Dec 15 05:10:17 node-1 dovecot: auth: Debug: pam(user1,192.168.1.201): allow_nets: Matching for network 192.168.1.0/24
======================================================================

EFS(Dockerfile)の記載について注意

  Dockerfileにefsのマウントパス宛に、ファイルコピーを行うと ECSのサービス作成時に、コンテナのデプロイ失敗に(container run time error)になるので 別経由で、EFSにファイルをコピーした方が良い!! <Dockerfile> ...