mirror of
https://github.com/imthenachoman/How-To-Secure-A-Linux-Server.git
synced 2026-11-02 03:08:19 +01:00
Add MSMTP
This commit is contained in:
1 parent
abbfa7e308
commit
73bb1990ec
1 file changed
+63
-20
@@ -54,7 +54,7 @@ An evolving how-to guide for securing a Linux server that, hopefully, also teach
|
|||||||
- [OSSEC - Host Intrusion Detection](#ossec---host-intrusion-detection)
|
- [OSSEC - Host Intrusion Detection](#ossec---host-intrusion-detection)
|
||||||
- [The Danger Zone](#the-danger-zone)
|
- [The Danger Zone](#the-danger-zone)
|
||||||
- [The Miscellaneous](#the-miscellaneous)
|
- [The Miscellaneous](#the-miscellaneous)
|
||||||
- [SSMTP (Simple Sendmail) with google](#ssmtp)
|
- [MSMTP (Simple Sendmail) with google](#msmtp)
|
||||||
- [Gmail and Exim4 As MTA With Implicit TLS](#gmail-and-exim4-as-mta-with-implicit-tls)
|
- [Gmail and Exim4 As MTA With Implicit TLS](#gmail-and-exim4-as-mta-with-implicit-tls)
|
||||||
- [Separate iptables Log File](#separate-iptables-log-file)
|
- [Separate iptables Log File](#separate-iptables-log-file)
|
||||||
- [Left Over](#left-over)
|
- [Left Over](#left-over)
|
||||||
@@ -3085,7 +3085,7 @@ Keep in mind, deborphan finds packages that have **no package dependencies**. Th
|
|||||||
|
|
||||||
## The Miscellaneous
|
## The Miscellaneous
|
||||||
|
|
||||||
### The Simple way with SSMTP(#ssmtp)
|
### The Simple way with MSMTP(#msmtp)
|
||||||
|
|
||||||
#### Why
|
#### Why
|
||||||
|
|
||||||
@@ -3094,31 +3094,74 @@ Well I will SIMPLIFY this method, to only output email using google mail account
|
|||||||
``` bash
|
``` bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
###### PLEASE .... EDIT IT...
|
###### PLEASE .... EDIT IT...
|
||||||
MYEMAIL="mail@gmail.com"
|
USRMAIL="usernameemail"
|
||||||
PWDEMAIL="plalala" ## ATTENTION DONT USE Special Chars.. like as SPACE # and some others not all. Feel free to test ;)
|
|
||||||
MAILPROV="smtp.google.com:583"
|
|
||||||
DOMPROV="gmail.com"
|
DOMPROV="gmail.com"
|
||||||
|
PWDEMAIL="passwordStrong" ## ATTENTION DONT USE Special Chars.. like as SPACE # and some others not all. Feel free to test ;)
|
||||||
|
MAILPROV="smtp.google.com:583"
|
||||||
|
MYMAIL="$USRMAIL@$DOMPROV"
|
||||||
USERLOC="root"
|
USERLOC="root"
|
||||||
#######
|
#######
|
||||||
apt install -y ssmtp
|
apt install -y msmtp
|
||||||
cp -r --preserve /etc/ssmtp /etc/ssmtp.bck
|
ln -s /usr/bin/msmtp /usr/sbin/sendmail
|
||||||
echo "AuthUser=$MYEMAIL
|
#wget http://www.cacert.org/revoke.crl -O /etc/ssl/certs/revoke.crl
|
||||||
AuthPass=$PWDEMAIL
|
#chmod 644 /etc/ssl/certs/revoke.crl
|
||||||
root=$MYEMAIL
|
touch /root/.msmtprc
|
||||||
mailhub=$MAILPROV
|
cat <<EOF> .msmtprc
|
||||||
hostname=$HOSTNAME
|
defaults
|
||||||
FromLineOverride=YES
|
account gmail
|
||||||
UseTLS=Yes
|
host $MAILPROV
|
||||||
UseSTARTTLS=YES
|
port $MAILPORT
|
||||||
RewriteDomain=$DOMPROV" > /etc/ssmtp/ssmtp.conf
|
#proxy_host 127.0.0.1
|
||||||
echo "$USERLOC:$MYEMAIL:$MAILPROV" >> /etc/ssmtp/revaliases ## USERLOC = root
|
#proxy_port 9001
|
||||||
chmod -R 0640 /etc/ssmtp
|
from $MYEMAIL
|
||||||
sleep 1
|
timeout off
|
||||||
echo "Test message from Hardened Linux server using ssmtp" | sendmail -v $MYEMAIL
|
protocol smtp
|
||||||
|
#auto_from [(on|off)]
|
||||||
|
#from envelope_from
|
||||||
|
#maildomain [domain]
|
||||||
|
auth on
|
||||||
|
user $USRMAIL
|
||||||
|
passwordeval "gpg -q --for-your-eyes-only --no-tty -d /root/msmtp-mail.gpg"
|
||||||
|
#passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt /root/msmtp-mail.gpg"
|
||||||
|
tls on
|
||||||
|
tls_starttls on
|
||||||
|
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||||
|
#tls_crl_file /etc/ssl/certs/revoke.crl
|
||||||
|
#tls_fingerprint [fingerprint]
|
||||||
|
#tls_key_file [file]
|
||||||
|
#tls_cert_file [file]
|
||||||
|
tls_certcheck on
|
||||||
|
tls_force_sslv3 on
|
||||||
|
tls_min_dh_prime_bits 512
|
||||||
|
#tls_priorities [priorities]
|
||||||
|
#dsn_notify (off|condition)
|
||||||
|
#dsn_return (off|amount)
|
||||||
|
#domain argument
|
||||||
|
#keepbcc off
|
||||||
|
logfile /var/log/mail.log
|
||||||
|
syslog on
|
||||||
|
account default : gmail
|
||||||
|
EOF
|
||||||
|
chmod 0400 /root/.msmtprc
|
||||||
|
|
||||||
|
## In testing .. auto command
|
||||||
|
# echo -e "1\n4096\n\ny\n$MYUSRMAIL\n$MYEMAIL\nmy key\nO\n$PWDMAIL\n$PWDMAIL\n" | gpg --full-generate-key
|
||||||
|
##
|
||||||
|
gpg --full-generate-key
|
||||||
|
gpg --output revoke.asc --gen-revoke $MYEMAIL
|
||||||
|
echo -e "$PWDEMAIL\n" | gpg -e -o /root/msmtp-mail.gpg --recipient $MYEMAIL
|
||||||
|
echo "export GPG_TTY=\$(tty)" >> .baschrc
|
||||||
|
chmod 400 msmtp-mail.gpg
|
||||||
|
|
||||||
|
echo "Hello there" | msmtp --debug $MYEMAIL
|
||||||
|
echo"######################
|
||||||
|
## MSMTP Configured ##
|
||||||
|
######################"
|
||||||
```
|
```
|
||||||
|
|
||||||
DONE!! ;)
|
DONE!! ;)
|
||||||
|
|
||||||
|
|
||||||
### Gmail and Exim4 As MTA With Implicit TLS
|
### Gmail and Exim4 As MTA With Implicit TLS
|
||||||
|
|
||||||
#### Why
|
#### Why
|
||||||
|
|||||||
Reference in new issue
Block a user