How to install Fail2Ban Ubuntu to block attacks to wordpress xmlrpc

fail2ban-xmlrpc

This is a very rough guide to be used only as guidance when setting up fail2ban. This simple setup should work on a low traffic server.

1. Install fail2ban

sudo apt-get update
sudo apt-get install fail2ban

2. Add a filter

Go to /etc/fail2ban/filter.d
Create a file called apache-xmlrpc.conf

On this file add:

[Definition]
failregex = ^<HOST> .*POST .*xmlrpc\.php.*
ignoreregex =

3. Enable the filter

Go to /etc/fail2ban/jail.conf

On this file add the following:

[apache-xmlrpc-access]

enabled  = true
port     = http,https
filter   = apache-xmlrpc
logpath  = /var/log/apache*/*access.log
maxretry = 6

You can change the maxretry set your log path.

4. Finish up by restarting fail2ban

sudo service fail2ban restart

5. Start fail2ban after reboot

Bonus: Set fail2ban to start after a reboot

Add EBS based swap to an EC2 instance

Add EBS Swap To AWS EC2 Instance
1. Create a new EBS volume of around 4-8GB and attach it to your instance.
We will assume the volume is /dev/xvdb
To check wether it is mounted use lsblk

2. If your volume is mounted, unmount it

sudo umount /dev/xvdb

3. Turn this volume into swap

sudo mkswap /dev/xvdb

4. Enable this volume as swap

sudo swapon /dev/xvdb

5. Make sure it is working as swap

swapon -s

6. Use this disk as swap if instance is restarted

sudo vim /etc/fstab

Add this:

/dev/xvdb       none    swap    sw  0       0

Add New EBS Volume to EC2 Instance

add-ebs-volume-to-ec2
A short, 3 step guide on how to add a new volume to your EC2 Instance.

Replace #### with your volume and #folder# with your folder path.

1. Format the disk

[ubuntu ~]$ sudo mkfs -t ext4 /dev/####

2. Mount the disk

[ubuntu ~]$ sudo mount /dev/#### #folder#

3. Auto-mount the volume on restart

[ubuntu ~]$ sudo vim /etc/fstab

fstab config

/dev/#### #folder# ext4 defaults 0 1