Enter your email address:

Delivered by FeedBurner

DenyHosts


StumbleUpon Toolbar

Whenever you need to left open the port 22 for ssh you machine from every where,but want to prevent Dictionary attacks, you can use DenyHosts to stay protected

First thing you need as DenyHost runs as a python script, is to be sure you python installed.

On Ubuntu or debian

apt-get install python wget

then get DenyHosts itself from its page.

here,
or if using Debian or Ubuntu you can just enter:

apt-get install denyhosts

and go directly to edit the configuration file, if you want to have it from the source, follow to the next step.

tar xvzf DenyHosts-2.6.tar.gz

cd DenyHosts-2.6

python setup.py install

Now, you should configure to fit your needs, first copy the conf file example

cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg

Now edit the denyhosts.cfg

vi /usr/share/denyhosts/denyhosts.cfg

and make sure you have this two options how your distro of Linux needs

    SECURE_LOG = /var/log/auth.log

    LOCK_FILE = /var/run/denyhosts.pid 

The above example is for Debian / Ubuntu, etc.

Here you have how should be for some of other Linux distributions

# Redhat or Fedora Core:
#SECURE_LOG = /var/log/secure
#
# Mandrake, FreeBSD or OpenBSD:
#SECURE_LOG = /var/log/auth.log
#
# SuSE:
#SECURE_LOG = /var/log/messages

Now make it possible for DenyHosts to run as a daemon

cd /usr/share/denyhosts
cp daemon-control-dist daemon-control
vi daemon-control

Make sure this is like your distro needs

###############################################
#### Edit these to suit your configuration ####
###############################################

DENYHOSTS_BIN   = "/usr/bin/denyhosts.py"
DENYHOSTS_LOCK  = "/var/lock/subsys/denyhosts"
DENYHOSTS_CFG   = "/usr/share/denyhosts/denyhosts.cfg"

PYTHON_BIN      = "/usr/bin/env python"

for Ubuntu / Debian you should change the

###############################################
#### Edit these to suit your configuration ####
###############################################

DENYHOSTS_LOCK  = "/var/lock/subsys/denyhosts.pid"

Make sure the root owns the daemon-control file, and the permissions are 700

so

chown root:root daemon-control

chmod 700 daemon-control

Now lets creat the link for the daemon-control script

cd /etc/init.d
ln -s /usr/share/denyhosts/daemon-control denyhosts
update-rc.d denyhosts defaults
/etc/init.d/denyhosts start

In RedHat Distributions you should do.

cd /etc/init.d
ln -s /usr/share/denyhosts/daemon-control denyhosts
chkconfig --add denyhosts && chkconfig denyhosts on
service denyhosts start

Trackback URL for this post:

http://www.go2linux.org/trackback/6
StumbleUpon Toolbar

 If you like this article, subscribe to our full rss

If this article was somehow useful for you, you can leave something in the tip's jar

Please post your question in our forum and use comments only to leave your comments about the article, thanks.

Thak's for tutorial.

Thak's for tutorial.

Thank's.... is very good and

Thank's.... is very good and simple....

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

This site is proudly hosted at Bluefur Hosting