Created
November 30, 2009 18:24
-
-
Save caironoleto/245614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "Type your domain: " domain | |
apt-get install postfix postfix-tls libsasl2-2 sasl2-bin libsasl2-modules telnet | |
cp /etc/postfix/sasl/smtpd.conf /etc/postfix/sasl/smtpd.conf.backup | |
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf | |
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf | |
mkdir /etc/postfix/ssl | |
cd /etc/postfix/ssl/ | |
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024 | |
chmod 600 smtpd.key | |
openssl req -new -key smtpd.key -out smtpd.csr | |
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt | |
openssl rsa -in smtpd.key -out smtpd.key.unencrypted | |
mv -f smtpd.key.unencrypted smtpd.key | |
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650 | |
cp /etc/postfix/main.cf /etc/postfix/main.cf.backup | |
echo "# See /usr/share/postfix/main.cf.dist for a commented, more complete version | |
smtpd_banner = \$myhostname ESMTP \$mail_name (Jus Navingadi) | |
biff = no | |
# appending .domain is the MUA's job. | |
append_dot_mydomain = no | |
# Uncomment the next line to generate "delayed mail" warnings | |
#delay_warning_time = 4h | |
myhostname = smtp.$domain | |
alias_maps = hash:/etc/aliases | |
alias_database = hash:/etc/aliases | |
myorigin = $domain | |
mydestination = smtp.$domain, localhost.$domain, localhost | |
relayhost = | |
mynetworks = 127.0.0.0/8 | |
mailbox_command = | |
mailbox_size_limit = 0 | |
recipient_delimiter = + | |
inet_interfaces = all | |
smtpd_sasl_local_domain = | |
smtpd_sasl_auth_enable = yes | |
smtpd_sasl_security_options = noanonymous | |
broken_sasl_auth_clients = yes | |
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination | |
smtpd_tls_auth_only = no | |
smtp_use_tls = yes | |
smtpd_use_tls = yes | |
smtp_tls_note_starttls_offer = yes | |
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key | |
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt | |
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem | |
smtpd_tls_loglevel = 1 | |
smtpd_tls_received_header = yes | |
smtpd_tls_session_cache_timeout = 3600s | |
tls_random_source = dev:/dev/urandom" > /etc/postfix/main.cf | |
cp /etc/default/saslauthd /etc/default/saslauthd.backup | |
echo "START=yes | |
# Description of this saslauthd instance. Recommended. | |
# (suggestion: SASL Authentication Daemon) | |
DESC=\"SASL Authentication Daemon\" | |
# Short name of this saslauthd instance. Strongly recommended. | |
# (suggestion: saslauthd) | |
NAME=\"saslauthd\" | |
# Which authentication mechanisms should saslauthd use? (default: pam) | |
# | |
# Available options in this Debian package: | |
# getpwent -- use the getpwent() library function | |
# kerberos5 -- use Kerberos 5 | |
# pam -- use PAM | |
# rimap -- use a remote IMAP server | |
# shadow -- use the local shadow password file | |
# sasldb -- use the local sasldb database file | |
# ldap -- use LDAP (configuration is in /etc/saslauthd.conf) | |
# | |
# Only one option may be used at a time. See the saslauthd man page | |
# for more information. | |
# | |
# Example: MECHANISMS=\"pam\" | |
MECHANISMS=\"pam\" | |
# Additional options for this mechanism. (default: none) | |
# See the saslauthd man page for information about mech-specific options. | |
MECH_OPTIONS="" | |
# How many saslauthd processes should we run? (default: 5) | |
# A value of 0 will fork a new process for each connection. | |
THREADS=5 | |
# Other options (default: -c -m /var/run/saslauthd) | |
# Note: You MUST specify the -m option or saslauthd won't run! | |
# | |
# WARNING: DO NOT SPECIFY THE -d OPTION. | |
# The -d option will cause saslauthd to run in the foreground instead of as | |
# a daemon. This will PREVENT YOUR SYSTEM FROM BOOTING PROPERLY. If you wish | |
# to run saslauthd in debug mode, please run it by hand to be safe. | |
# | |
# See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information. | |
# See the saslauthd man page and the output of 'saslauthd -h' for general | |
# information about these options. | |
# | |
# Example for postfix users: \"-c -m /var/spool/postfix/var/run/saslauthd\" | |
OPTIONS=\"-c -m /var/spool/postfix/var/run/saslauthd -r\" | |
" > /etc/default/saslauthd | |
mkdir -p /var/spool/postfix/var/run/saslauthd | |
adduser postfix sasl | |
/etc/init.d/saslauthd start | |
/etc/init.d/postfix restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment