Difference between revisions of "Denyhosts"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
Line 15: Line 15:
  
 
== Faulty Denials ==
 
== Faulty Denials ==
If you get denied because you're fat-fingered or your automatic ssh login is configured wrong, you'll need to be removed from the denial list. Thankfully, we have a script at '''/usr/local/bin/denyhosts-undeny.py''' on all the machines running denyhosts. Just specify the host to undeny as the only argument, and it'll clean it all up for you. Currently, it only works on CentOS and RedHat, but it should be simple to add functionality for other distros.
+
 
 +
The Denyhosts FAQ gives these instructions for correcting erroneous denials:
 +
 
 +
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 files. In order to cleanse the address you will need to do the following:
 +
 
 +
  1. Stop DenyHosts
 +
  2. Remove the IP address from /etc/hosts.deny
 +
  3. Edit WORK_DIR/hosts and remove the lines containing the IP address. Save the file.
 +
  4. Edit WORK_DIR/hosts-restricted and remove the lines containing the IP address. Save the file.
 +
  5. Edit WORK_DIR/hosts-root and remove the lines containing the IP address. Save the file.
 +
  6. Edit WORK_DIR/hosts-valid and remove the lines containing the IP address. Save the file.
 +
  7. Edit WORK_DIR/user-hosts and remove the lines containing the IP address. Save the file.
 +
  8. (optional) Consider adding the IP address to WORK_DIR/allowed-hosts
 +
  9. Start DenyHosts
 +
 
 +
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.  
 +
 
 +
We have a script at '''/usr/local/bin/denyhosts-undeny.py''' on all the machines running denyhosts that should do this automatically. Just specify the host to undeny as the only argument, and it'll clean it all up for you. Currently, it only works on CentOS and RedHat, but it should be simple to add functionality for other distros.

Revision as of 15:56, 19 January 2010

Intro

We run a python script called "denyhosts.py" on our servers. This script looks at failed login attempts and if there are too many will deny all further access from that system.

Quick Install

The RPM is located at: einstein:/root/Packages/DenyHosts-2.6-python2.4.noarch.rpm

  1. Copy from einstein the /etc/denyhosts.conf file.
  2. Copy from einstein the /etc/sysconfig/denyhosts file.
  3. Copy from einstein the /usr/bin/denyhosts-control file.
  4. Copy from einstein the /etc/init.d/denyhosts file.
  5. Execute "chkconfig --add denyhosts; chkconfig --level 345 denyhosts on
  6. Start it up: service denyhosts start

Faulty Denials

The Denyhosts FAQ gives these instructions for correcting erroneous denials:

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 files. In order to cleanse the address you will need to do the following:

  1. Stop DenyHosts
  2. Remove the IP address from /etc/hosts.deny
  3. Edit WORK_DIR/hosts and remove the lines containing the IP address. Save the file.
  4. Edit WORK_DIR/hosts-restricted and remove the lines containing the IP address. Save the file.
  5. Edit WORK_DIR/hosts-root and remove the lines containing the IP address. Save the file.
  6. Edit WORK_DIR/hosts-valid and remove the lines containing the IP address. Save the file.
  7. Edit WORK_DIR/user-hosts and remove the lines containing the IP address. Save the file.
  8. (optional) Consider adding the IP address to WORK_DIR/allowed-hosts
  9. Start DenyHosts 

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.

We have a script at /usr/local/bin/denyhosts-undeny.py on all the machines running denyhosts that should do this automatically. Just specify the host to undeny as the only argument, and it'll clean it all up for you. Currently, it only works on CentOS and RedHat, but it should be simple to add functionality for other distros.