Monthly Archives: March 2015

hMailServer Anti Spam Settings

Update: 12/19/2015

While the below settings work well for the built in hMailServer anti spam, I have since moved to ASSP on a separate server for spam filtering.  It is by far the most effective solution I have ever used and I highly recommend it!  As a basis for comparison, when I was using the below setup I would routinely get 5+ spam emails a day slip through the filter.  Now that I have ASSP well tuned and up and running for 6 months I may get 1 spam per week that slipped through.


 

Antispam->General
Spam Mark Threshold = 6
Spam Delete Threshold = 9
Max Message Size to Scan = 1024
All tickboxes selected.

Antispam->Spam Tests
Use SPF = 3
Check host in HELO = 2
Check DNS MX = 2
Verify DKIM = 5

Antispam->Tarpitting
Count 0
Delay 15

Antispam->DNS Blacklists
zen.spamhaus.org | 127.0.0.* | Server rejected by http://www.spamhaus.org/zen/ | Score = 5 | (Old Settings 127.0.0.2-8|127.0.0.10-11)
psbl.surriel.com | 127.0.0.* | Server rejected by surriel.com | Score = 1
b.barracudacentral.org | 127.0.0.* | Server rejected by barracuda | Score = 4
bl.spamcop.net | 127.0.0.* | Server rejected by SpamCop.net | Score = 4
dnsbl.sorbs.net | 127.0.0.* | Server rejected by Sorbs.net | Score = 1

Antispam->SURBL Servers
multi.surbl.org | Rejected by SURBL | Score = 4

Antispam->Greylisting
Minutes to Defer = 1
Days to remove unused = 1
Days to remove used = 72
Tick Bypass on SPF

WordPress Force Login WP-Cron & BackWPup Not Working

When using the Force Login plugin for wordpress by Kevin Vess, you will notice that WP-Cron and external links to launch backups for BackWPup no longer work.

The developer wrote some fixes for this thankfully, however it can be confusing for non technical people if you have no programming experience.

To enable XMLRPC, edit wp-force-login.php in the plugin directory, and replace the second function in the file from the one on his GitHub.

For my particular use case, I needed to be able to call a backup job for BackWPup from one of my other servers with CURL.  I used his fix for WP-Cron, but edited it to not require authentication from my home server’s public IP address.  There was also a small syntax error that needed correcting.  Again, we will be replacing the second function in the plugin.

Original Plugin file:

< ?php
/*
Plugin Name: Force Login
Plugin URI: http://vess.me/
Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
Version: 2.1
Author: Kevin Vess
Author URI: http://vess.me/
License: GPLv2 or later
*/

/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

function v_getUrl() {
  $url  = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
  $url .= '://' . $_SERVER['SERVER_NAME'];
  $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
  $url .= $_SERVER['REQUEST_URI'];
  return $url;
}
function v_forcelogin() {
  $url = v_getUrl();
  if( !is_user_logged_in() && preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) ) {
    wp_safe_redirect( wp_login_url( $url ), 302 ); exit();
  }
}
add_action('init', 'v_forcelogin');

Edited plugin to allow WP-Cron to function (Link Here):

< ?php
/*
Plugin Name: Force Login
Plugin URI: http://vess.me/
Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
Version: 2.1
Author: Kevin Vess
Author URI: http://vess.me/
License: GPLv2 or later
*/

/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

function v_getUrl() {
  $url  = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
  $url .= '://' . $_SERVER['SERVER_NAME'];
  $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
  $url .= $_SERVER['REQUEST_URI'];
  return $url;
}
function v_forcelogin() {
  $url = v_getUrl();
  if( !is_user_logged_in() && preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) ) {
    if( $_SERVER['REMOTE_ADDR'] != 'xxx.xxx.xxx.xxx' ) {
      wp_safe_redirect( wp_login_url( $url ), 302 ); exit();
    }
  }
}
add_action('init', 'v_forcelogin');

Make sure that you wrap the IP address from which you need to connect without authentication is wrapped in apostrophies EX:

 != '127.0.0.1'

SSH Authentication Key Setup Ubuntu

Here is how to set up key based authentication for OpenSSH server on Ubuntu 14.04

First, generate your keypair for the account.  You can leave the private key password blank if you do not want to enter one every time.

cperson@WEB:~/.ssh$ ssh-keygen -t rsa

Copy your private key to your computer.  You may need to use PuTTYgen to convert it for use with PuTTY.

Enable your account for logon with the private key by adding your public  key to the authorized_keys file.

cperson@WEB:~/.ssh$ cat id_rsa.pub >> authorized_keys

Free up Disk Space on /boot

Occasionally you will need to free up some disk space on the /boot partition after updating your kernel several times.  Here are a few commands to list all installed kernels on your Ubuntu system, except the running one.

kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver

List all installed kernels:

dpkg -l linux-image-\* | grep ^ii

Then, you can remove the un needed kernels with this command:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")