Installing Denyhosts on CentOS

At first download an rpm

wget http://centos.karan.org/el4/extras/stable/i386/RPMS/denyhosts-2.5-1.el4.kb.noarch.rpm

Then
rpm -i denyhosts-2.5-1.el4.kb.noarch.rpm

chkconfig denyhosts on

modify /etc/denyhosts.conf as per your requirements

and then

service denyhosts start

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

root@fastnu [~]# 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

Eewww there is a patch of it available at

here

What you need to do is to change /usr/bin/denyhosts and make it

#!/usr/bin/env python2.4

then service denyhosts start
However if this still doesnt work then you might have multiple version of python installed
over your machine “Thats what happened with me :p”

Go into cd /usr/lib/
then
root@fastnu [/usr/lib]# ls -la | grep python
lrwxrwxrwx 1 root root 19 Mar 18 10:11 libpython2.4.so -> libpython2.4.so.1.0*
-r-xr-xr-x 1 root root 1136208 Mar 14 2007 libpython2.4.so.1.0*
drwxr-xr-x 3 root root 4096 May 9 09:37 python2.3/
drwxr-xr-x 22 root root 20480 Mar 18 06:30 python2.4/
root@fastnu [/usr/lib]#

I see python2.3 and python2.4 and when and in python2.3 site-packages directory i can see
Denyhosts package so what i did was to move it from python2.3/site-packages/Denyhosts to
python2.4/site-packages/Denyhosts

and did service denyhosts start

starting DenyHosts: /usr/bin/python2.4 /usr/bin/denyhosts.py –daemon –config=/etc/denyhosts.conf

This is it :) all good !

~ by azimyasin on May 9, 2008.

10 Responses to “Installing Denyhosts on CentOS”

  1. Thanks for the last part. The one thing I was missing was to move DenyHosts to my python2.5/site-packages directory.

  2. Same here, thank you so much for sharing :)
    Michal

  3. thnx buat tutor nya mas :)

  4. Hi!
    do you use any particular customization on denyhosts.cfg file ?

  5. kudos, nice tutorial, was struggling with this.

  6. cool thanks
    just on question will that run automaticly when the server restarts

    thanks again

  7. if you want it to run automatically and your on CENTOS / FC / RedHat / then just run the ntsysv command and select it from the list put an asterisk in it and tab to okay, if your running another kernal, then google linux programs to run on startup and that should get you pointed in the right direction

  8. Also I set my file to use the global list as it will grab the top known attacking IP addresses, and will submit ones to the list that attack you. If more people ran this “that way” then i think there would be alot of people abandoning using ssh attacks, i set mine to block ALL services not just SSH, this way if someone i know can’t see my webserver, then I know to check my logs ;)

  9. Thank you, great tutorial

  10. Thank you, it was my case too and you did help me a lot!

Leave a Reply