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.
1. Install DenyHosts via apt
[shell]sudo apt-get install denyhosts[/shell]
2. Whitelist you IP Addresses
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.
To insert you IP, open this file:
[shell]sudo nano /etc/hosts.allow[/shell]
under the description, add in any IP addresses e.g. your IP so that you will not kicked out from the server. You can write each one on a separate line, using this format:
[shell]
sshd: 12.34.45.678
sshd: 89.76.54.321
[/shell]
After making any changes, be sure to restart DenyHosts so that the new settings take effect on your virtual private server:
[shell]sudo /etc/init.d/denyhosts restart[/shell]
3. Configure DenyHosts (Optional)
If you want to customize the behavior of DenyHosts on your VPS, you can make the changes within the DenyHost configuration file:
[shell]sudo nano /etc/denyhosts.conf[/shell]