For best practice to hardening servers we typically install denyhosts to protect our servers. However, sometimes we get accidentally blocked out from our IP address. When we tried removing blocked IP from /etc/hosts.deny, but it did blocked it again quickly. It appears that DenyHosts keeps track of the attempts somewhere on disk or memory. How do we remove own IP address from Deny Hosts?
Simply removing your IP from /etc/hosts.deny does not work since DenyHosts keeps track of the attempts in the /var/lib/denyhosts/ directory. In order to remove your IP address you will need to do the following.
Simply removing your IP from /etc/hosts.deny does not work since DenyHosts keeps track of the attempts in the /var/lib/denyhosts/ directory. In order to remove your IP address you will need to do the following.
Step # 1: Stop DenyHosts
# /etc/init.d/denyhosts stop
Step # 2: Remove Your IP From /etc/hosts.deny
# vi /etc/hosts.deny
Delete your IP address. Save and close the file.
Delete your IP address. Save and close the file.
Step # 3: Remove Your IP From /var/lib/denyhosts/ Directory
Cd to /var/lib/denyhosts/
# cd /var/lib/denyhosts/
You need to edit the following files using vi and remove the lines containing the IP address. Save the file.
1. hosts
2. hosts-restricted
3. hosts-root
4. hosts-valid
5. users-hosts
If you've static IP address add to allowed-hosts file. Any IP address that appears in this file will not be blocked by default (consider this as a whilelist):
# echo '1.2.3.4' >> allowed-hosts
Step # 4: Start DenyHosts
# /etc/init.d/denyhosts start
No comments:
Post a Comment