DenyHosts is a security tool written in python that monitors server access logs to prevent brute force attacks on a virtual private server.The program works by banning IP addresses that exceed a certain number of failed login attempts.
Ubuntu:
sudo apt-get install denyhosts
CentOS:
sudo yum install denyhosts
After you install DenyHosts, make sure to whitelist your own IP address. Skipping this step will put you at risk of locking yourself out of your own machine!
edit /etc/hosts.allow & add the following: Along with any other trusted IP Adresses
ALL: localhost ALL: 127.0.0.1
Save, and restart denyhosts
/etc/init.d/denyhosts restart
Email Alerts, you can change denyhosts config by editing /etc/denyhosts/denyhosts.cfg
Comment out the following line to not recieve emails, or add your email address to it if you do want notification every time an ip address is blocked.
#ADMIN_EMAIL =