HOWTO unblock an IP that’s been blocked by DenyHosts
This is one of the questions of the FAQs of DenyHosts and you can find it here.
To save you a click, the relevant section of the page says, as of Jan 21, 2010:
If you have been accidentally locked out of one of your hosts (because DenyHosts has added it to /etc/hosts.deny you may have noticed that simply removing it from /etc/hosts.deny does not in itself correct the issue) since DenyHosts keeps track of the attempts in the WORK_DIR (/var/lib/denyhosts by default) files. In order to cleanse the address you will need to do the following:
- Stop DenyHosts (”sudo /etc/init.d/denyhosts stop”)
- Remove the IP address from /etc/hosts.deny
- Edit WORK_DIR/hosts and remove the lines containing the IP address. Save the file.
- Edit WORK_DIR/hosts-restricted and remove the lines containing the IP address. Save the file.
- Edit WORK_DIR/hosts-root and remove the lines containing the IP address. Save the file.
- Edit WORK_DIR/hosts-valid and remove the lines containing the IP address. Save the file.
- Edit WORK_DIR/users-hosts and remove the lines containing the IP address. Save the file.
- (optional) Consider adding the IP address to ”’WORK_DIR/allowed-hosts”’
- Start DenyHosts (”sudo /etc/init.d/denyhosts start”)
Note: Not all of the WORK_DIR files will contain the IP address so you may want to use grep to determine which files contain the IP address.
Here is a list of commands for copy-paste:
-
sudo /etc/init.d/denyhosts stop
-
sudo vim /etc/hosts.deny
-
sudo vim /var/lib/denyhosts/hosts
-
sudo vim /var/lib/denyhosts/hosts-restricted
-
sudo vim /var/lib/denyhosts/hosts-root
-
sudo vim /var/lib/denyhosts/hosts-valid
-
sudo vim /var/lib/denyhosts/users-hosts
- (optional)
sudo vim /var/lib/denyhosts/allowed-hosts
-
sudo /etc/init.d/denyhosts start