2016年3月7日 星期一

(insecure) Mail Server setup and config

Purpose: a Server hosting insecure SMPT/POP3 and Web Mail service

  • SMTP Server       192.168.136.25:25
  • POP3 Server       192.168.136.110:110
  • Webmail Server    192.168.136.80:80

Pre-config Account:

  • kitty:hello
  • daniel:hello


Reference:

https://www.howtoforge.com/perfect-server-ubuntu-14.04-apache2-php-mysql-pureftpd-bind-dovecot-ispconfig-3-p6

Answer:


Binding extra three IPv4 addresses binding with the same network interface

$ ifconfig | grep Ethernet | awk '{print $1}' | awk '{ printf("sudo ifconfig %s:0 192.168.136.53\nsudo ifconfig %s:1 192.168.136.25\nsudo ifconfig %s:2 192.168.136.110\nsudo ifconfig %s:3 192.168.136.80\n", $1, $1, $1, $1); }'



$ sudo apt-get -y install postfix





$ sudo vim /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = no
readme_directory = no
# TLS parameters
# smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.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
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = server
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = lab.local, server, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.136.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all


$ sudo vim /etc/postfix/master.cf
smtp      inet  n       -       -       -       -       smtpd
submission inet n       -       -       -       -       smtpd
  -o smtpd_sasl_auth_enable=no


$ sudo service postfix start

$ sudo apt-get install -y dovecot-pop3d dovecot-gssapi dovecot-imapd



$ sudo vim /etc/dovecot/dovecot.conf

protocols = pop3 imap
listen = *
login_greeting = mail server ready by Dovecot
login_trusted_networks = 192.168.136.0/24
disable_plaintext_auth = no

$ sudo service dovecot restart

$ sudo apt-get install -y squirrelmail apache2

$ sudo squirrelmail-configure





$ sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail.conf

$ sudo ln -s /etc/apache2/sites-available/squirrelmail.conf /etc/apache2/sites-enabled/squirrelmail.conf

$ sudo vim /etc/apache2/sites-available/squirrelmail.conf

$ sudo ln -s /etc/squirrelmail/apache.conf /etc/apache2/conf-available/squirrelmail.conf

$ sudo vim /etc/apache2/conf-available/squirrelmail.conf

Alias /mail /usr/share/squirrelmail

<Directory /usr/share/squirrelmail>
  Options FollowSymLinks
  <IfModule mod_php5.c>
    AddType application/x-httpd-php .php
    php_flag magic_quotes_gpc Off
    php_flag track_vars On
    php_admin_flag allow_url_fopen Off
    php_value include_path .
    php_admin_value upload_tmp_dir /var/lib/squirrelmail/tmp
    php_admin_value open_basedir /usr/share/squirrelmail:/etc/squirrelmail:/var/lib/squirrelmail:/etc/hostname:/etc/mailname
    php_flag register_globals off
  </IfModule>
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>

  # access to configtest is limited by default to prevent information leak
  <Files configtest.php>
    order deny,allow
    deny from all
    allow from 127.0.0.1
  </Files>
</Directory>

$ sudo mkdir /var/lib/squirrelmail/tmp

$ sudo chown www-data /var/lib/squirrelmail/tmp

$ sudo a2ensite squirrelmail

$ sudo service apache2 reload

$ sudo useradd -m -s /usr/sbin/nologin kitty

$ echo kitty:hello | sudo /usr/sbin/chpasswd

$ sudo useradd -m -s /usr/sbin/nologin daniel

$ echo daniel:hello | sudo /usr/sbin/chpasswd


open web page with URL  http://192.168.136.80/mail/




沒有留言:

張貼留言