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
sudo apt-get install denyhosts
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:
sudo nano /etc/hosts.allow
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:
sshd: 22.214.171.1248 sshd: 126.96.36.1991
After making any changes, be sure to restart DenyHosts so that the new settings take effect on your virtual private server:
sudo /etc/init.d/denyhosts restart
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:
sudo nano /etc/denyhosts.conf