Monday, October 5, 2009

How to install Denyhosts in linux

How to install Denyhosts in linux
==================================

1.Download denyhosts from http://sourceforge.net/projects/denyhosts/files/

2.Pre-requisite
*Python 2.4 or Above

3.Check the SSH tcp_wrappers
*Login as a root user and edit the follwing file
*vim /ets/hosts.deny
*add the following line
*sshd: 127.0.0.1
*Save the file
*Attempt to connect to the local sshd server
*$ssh localhost
*You should see the follwing ssh error message:
*ssh_exchange_identification: Connection closed by remote host
*If the above error message was displayed , Then sshd has been compiled with tcp_wrappers
*If your clients to the sshe server, then your sshd has not been compiled with tcp_wrappers
*edit the file /etc/hosts.deny
*Remove the line that you added earlier (eg. sshd: 127.0.0.1 )
*Save the file

4. Extract the Denyhosts tar file
*tar -xvf DenyHosts-2.6.tar.gz
*mv DenyHosts-2.6 /usr/local/src/Denyhosts
*cd /usr/local/src/Denyhosts
*python setup.py install

5.Copy the sample cfg file
*cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg

6.Make denyhost as a daemon
*cp /usr/share/denyhosts/daemon-control-dist /etc/init.d/denyhosts
*cp /etc/init.d/denyhosts /etc/rc3.d/S99denyhosts
*cp /etc/init.d/denyhosts /etc/rc5.d/S99denyhosts
*/etc/init.d/denyhosts start

7.Configure denyhosts.cfg as you want
*vim /usr/share/denyhosts/denyhosts.cfg