Adding AUTH PLAIN to Postfix

Note Instructions are for debian (and probably works for ubuntu and friends too). Easiest way to getting it to work in fedora is through dovecot’s sasl2. See dovecot configuration and postfix configuration Install sasl dependencies sudo apt-get install libsasl2-modules sasl2-bin Create /etc/postfix/sasl/smtpd.conf: pwcheck_method: saslauthd mech_list: PLAIN LOGIN Create /etc/default/saslauthd-postfix cp /etc/default/saslauthd /etc/default/saslauthd-postfix Edit /etc/default/saslauthd-postfix START=yes DESC="SASL Auth. Daemon for Postfix" NAME="saslauthd-postf" # max. 15 char? OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd" Create subdirs: dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd Add group (maybe not required?...

Debian: Unattended upgrades

Description: Install unattended-upgrades. The server should run unattended upgrades every night, and reboot at 4 am if required by any application. Implementation: Login as root Install packages unattended-upgrades and cron-apt Set the following values in /etc/apt/apt.conf.d/50unattended-upgrades Unattended-Upgrade::Origins-Pattern { "o=Debian,a=stable"; }; Unattended-Upgrade::MinimalSteps "true"; Unattended-Upgrade::InstallOnShutdown "true"; Unattended-Upgrade::Mail "root"; Unattended-Upgrade::MailOnlyOnError "true"; Unattended-Upgrade::Remove-Unused-Dependencies "false"; Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "04:00"; Unattended-Upgrade::InstallOnShutdown "false"; Set the following values in /etc/apt/apt.conf.d/02periodic APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::AutocleanInterval "30"; Verification: Run unattended-upgrade --dry-run --debug as root....

Getting started with KVM

Installation (No X11) # Install prerequirements (ignore virtinst if you have x11) sudo apt-get install qemu-kvm libvirt-bin virtinst sudo usermod -aG kvm $USER sudo usermod -aG libvirt $USER Creating a new host (i.e. guest) # NAME-OF-VHOST is whatever you want to call your virtual host # SIZE-IN-MB is how many MBs of RAM you want to give the new host # LOCATION is the location to install from, you can find locations by typing `man virt-install` # NAME-OF-DISK is what disk you want to provide to the vhost, e....

Enabling angular-js html5mode

location ~ ^/(data|html|css|js)/ { try_files $uri $uri/ =404; } location / { try_files $uri $uri/ /index.html; }

Enabling angular-js html5mode

The first RewriteCond allows requests for files which already exists, The second RewriteCond allowed requests for directories which already exists, The third RewriteCond makes sure to not redirect any of the data, html, css or js directories The first RewriteRule says that if any of the RewriteCond matched, we do not do anything else (i.e. return from this function) The second RewriteRule says that if we have not returned from the previous RewriteRule we will return index....

Awk Cheatsheet

Links Awk tutorial Pattern matching (grep) # Should return one line per file ls -a | awk '//' # Should print files starting with a dot ls -a | awk '/^\./' Counting (wc) ls | awk '{i++} END {print i}' # Should return number of files Delete all svn-files with an exclamation mark in svn status svn status | awk '/^!/{print $2}' | xargs svn delete --force Find only the first match and print it echo data | awk "/$pattern/{print;exit}" Ignore the first line echo data | awk 'NR>1' Ignore duplicate lines echo data | awk '!...

March 24, 2016  |  🏷️Awk

Anti-spam with Spamassassin

Implementation: Login on server as root Install spamassassin through aptitude In /etc/default/spamassassin: Set ENABLED=1 Add/uncomment in /etc/spamassassin/local.cf: rewrite_header Subject *****SPAM***** report_safe 0 In /etc/postfix/master.cf: smtp inet n - - - - smtpd -o content_filter=spamassassin spamassassin unix - n n - - pipe user=debian-spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient} Restart services service spamassassin start service postfix reload Verification: Email sent to server with body XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X should have subject rewritten to ****SPAM**** $header

Autofs - Installing automounter with LDAP

Description: Setup autofs on machines client-1 and client-2, which both uses ldap (how to install is described in a previous note) Implementation: Install package autofs5-ldap Create autofs.ldif with the following data: dn: cn=autofs,cn=schema,cn=config objectClass: olcSchemaConfig cn: autofs olcAttributeTypes: {0}( 1.3.6.1.1.1.1.25 NAME 'automountInformation' DESC 'Inf ormation used by the autofs automounter' EQUALITY caseExactIA5Match SYNTAX 1. 3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) olcObjectClasses: {0}( 1.3.6.1.1.1.1.13 NAME 'automount' DESC 'An entry in an automounter map' SUP top STRUCTURAL MUST ( cn $ automountInformation $ object class ) MAY description ) olcObjectClasses: {1}( 1....

Courier - Installation

Description: Install courier on server Implementation: Login as root Install fam and courier-imap-ssl through aptitude Create directories for web-based administration? No In /etc/postfix/main.cf, add line: home_mailbox = Maildir/ Restart service service postfix restart You may need to run maildirmake Maildir when in homedir? Verification: Should be able to login as root on imap from outside of LAN Should be able to login as root on imap with STARTTLS from outside of LAN

January 14, 2016  |  🏷️Postfix

DNS/Bind9 - Configuring SPF

Description: Configure your DNS server to include SPF records for your domain. The only acceptable as a source of e-mail from your domain is your server. The SPF record should reflect this. Implementation: Add line to /etc/bind/db.d4.sysinst.ida.liu.se: @ IN TXT "v=spf1 mx -all" Restart service: service bind9 reload Verification: dig d4.sysinst.ida.liu.se TXT should return the above line Sending an email from server.d4.sysinst.ida.liu.se to e.g. a gmail should have a ‘Received-SPF: pass’ in the header....

January 14, 2016  |  🏷️Dns 🏷️Spf