Ossec + postfix (Is in writing)
Гайд:
sudo apt update && sudo apt upgrade -y
cd /tmp
wget https://github.com/ossec/ossec-hids/archive/3.6.0.tar.gz
# последние версии тут
# https://www.ossec.net/download-ossec/
# https://github.com/ossec/ossec-hids/releases
tar xfv 3.6.0.tar.gz
cd ossec-hids-3.6.0/
apt install libz-dev libssl-dev libpcre2-dev libevent-dev build-essential sendmail make gcc
ls
bash install.sh
# В диалоге выбираю:
# server
# ввожу свою почту maMail@gmail.com
# Do you want to use it (about email) as SMTP: no
# What's your SMTP server ip/host? localhost
# firewall-drop enabled (local) for levels >= 6
#- 127.0.0.53
# больше ip в белый список фаервола не ввожу
# More information at:
http://www.ossec.net/en/manual.html#ma
Теперь Настроим почту
cd /var/ossec
clear
ls
apt purge sendmail
apt autoremove
# на сайте есть гайды https://documentation.wazuh.com/current/user-manual/manager/manual-email-report/smtp-authentication.html
apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
# жмем ок
# выбираем Local only
# РЕДАКТИРУЕМ файл /etc/postfix/main.cf (пункт 2 сайта выше) видео 2 минута 1:14
nano /etc/postfix/main.cf
# удаляем из файла это
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destinat>
myhostname = AlexAgoric
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, AlexAgoric, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
default_transport = error
relay_transport = error
inet_protocols = all
# вставляем это
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/server.pem
smtp_use_tls = yes
# После настройки файла переходим
cd /etc/postfix
# проверим есть ли сертефикат
ls /etc/ssl/certs/ssl-cert-snakeoil.pem
# создим сертификаты в файле certreq.txt
openssl req -new -newkey rsa:2048 -nodes -out certreq.txt -keyout private.key
# все оставляем без пароля и без ввода (только энтер)
ls
# проверим
nano certreq.txt
# переименуем
mv certreq.txt cacert.pem
# теперь сделаем слияние двух сертификатов
cat /etc/ssl/certs/ssl-cert-snakeoil.pem cacert.pem > server.pem
# проверим
nano server.pem
# Теперь делаем доступ для почты
# https://documentation.wazuh.com/current/user-manual/manager/manual-email-report/smtp-authentication.html
echo [smtp.gmail.com]:587 maMail@gmail.com:'пароль' > /etc/postfix/sasl_passwd
# проверим файл
nano /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chmod 400 /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
systemctl reload postfix
# пробуем отправить с нашего ящика на наш же ящик
echo "Test mail from postfix" | mail -s "Test Postfix" -r "maMail@gmail.com" maMail@gmail.com
И тут проблема - после разрешения в гугле, тестовые сообщения все равно не приходят. В чем может быть проблема?Last updated