Installing DenyHosts on CentOS

1. Download & install the RPM.

user@server:$ wget http://centos.karan.org/el4/extras/stable/i386/RPMS/denyhosts-2.5-1.el4.kb.noarch.rpm
user@server:$ rpm -Uvh denyhosts-2.5-1.el4.kb.noarch.rpm
user@server:$ chkconfig denyhosts on

2. Modify /etc/denyhosts.conf to your requirements.

user@server:$ nano /etc/denyhosts.conf

3. Start service.

user@server:$ service denyhosts start

This is it you’re done however its not always that easy, some time you can get an error like this:

user@server:$ service denyhosts start
starting DenyHosts: /usr/bin/python /usr/bin/denyhosts.py –daemon –config=/etc/denyhosts.conf
Traceback (most recent call last):
File “/usr/bin/denyhosts.py”, line 5, in ?
import DenyHosts.python_version
ImportError: No module named DenyHosts.python_version

The first thing you want to check are the site packages.

user@server:$ cd /usr/lib/python2.4/site-packages/DenyHosts
user@server:$ ls
libpython2.4.so.1.0

Is there only one file like shown above? Then are all the files still stored in python2.3. Which causes the problem. What we are going to do is copy all of the files from python2.3 to python2.4.

user@server:$ cd /usr/lib/python2.3/site-packages/DenyHosts
user@server:$ cp * /usr/lib/python2.4/site-packages/DenyHosts

Now you have copied all the files to the python2.4 folder, try to start the service.

user@server:$ service denyhosts start
starting DenyHosts: /usr/bin/python2.4 /usr/bin/denyhosts.py –daemon –config=/etc/denyhosts.conf

It worked for me, so I hope it works for you too. If not.. Then you might have another problem. The only problem I can think of is that you have to change the /usr/bin/denyhosts to #!/usr/bin/env python2.4. You can read more about the bug HERE.

| More