First thing to do when setting up a Ubuntu Server is to make sure it’s secure. Install fail2ban to make sure you block IP-addresses that try to break in, and log everything with logwatch.
Update the system.
apt-get install fail2ban
Copy the configuration file.
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Edit the file.
sudo nano /etc/fail2ban/jail.local
Change the ban time from 600 (10 minutes) to 604800 (7 days) and CTRL + O to save and CTRL + X to exit.
bantime = 604800
apt-get install logwatch
Edit logwatch daily cron to email you the log.
Add this line at the bottom and replace the example email with your own. Save with CTRL + O and exit with CTRL + X.
/usr/sbin/logwatch --output mail --mailto firstname.lastname@example.org --detail high