Let's make the world a better place using digital technologies!

apt-get install fail2ban
That’s all it takes to install this handy utility. It will monitor different services (ssh, postfix, courier, etc.) for repeated failed login attempts and will block the attacker for a given duration of time. All the settings can be found in /etc/fail2ban/jail.conf.
After you have updated the settings file, use:/etc/init.d/fail2ban restart
to reload the new settings.

I was having brute-force dictionary attacks on pop3 port, fail2ban blocked the attacker within 1 minute. Thanks to the developers.