4

As I use SSH, I would like to get the denyhosts that I read about here, but when using the command:

sudo apt-get install denyhosts

To install it, I got this error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package denyhosts

So is this package no longer available then? Or is it just under a different name or something? If this package is no longer available on the main Ubuntu repositories, is there anywhere else from which I can get it?

OS Information:

Description:    Ubuntu 14.10
Release:    14.10
1
  • You can install denyhosts but it is not available in software channel, i have added an answer for downloading and installing denyhosts. Mar 3, 2015 at 20:56

2 Answers 2

7

Denyhosts is no longer available. You can use fail2ban or better, a few ssh tips.

  1. Use ssh keys and disable password authentication.

  2. iptables can do essentially the same thing as denyhosts and fail2ban . The advantage is no additional packages are required.

    iptables -A INPUT -p tcp -m tcp --dport 22 -m tcp -m state --state NEW -m recent --set --name SSH --rsource
    
    iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --update --seconds 600 --hitcount 8 --rttl --name SSH --rsource -j REJECT --reject-with icmp-host-prohibited
    
    iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
    

See:

http://bodhizazen.com/Tutorials/SSH_security

http://bodhizazen.com/Tutorials/iptables#Additional_Tips

On the second link, scroll down a bit. You will need to save and restore your iptables rules.

0

Run the commands below to download version 2.10

cd /tmp/ && wget http://cznic.dl.sourceforge.net/project/denyhost/denyhost-2.10/denyhosts-2.10.tar.gz

Next, run the commands below to extract it.

tar xzf denyhosts*.tar.gz

Then run the commands below to change into the extracted folder

cd DenyHosts*

Finally, run the commands below to install the program

sudo python setup.py install

After running the commands above, DenyHosts will be installed on your server but not fully configured You must manually configure the tool.

Copy the daemon file to the /etc/init.d/ directory.

sudo cp /usr/local/bin/daemon-control-dist /etc/init.d/denyhosts

Next, open the script (sudo vi /etc/init.d/denyhosts) and make the below highlighted change

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

DENYHOSTS_BIN="/usr/local/bin/denyhosts.py"
DENYHOSTS_LOCK="/run/denyhosts.pid" 
DENYHOSTS_CFG="/etc/denyhosts.conf"

PYTHON_BIN="/usr/bin/env python"

Once installed, its configured and ready to protect your servers. One thing most webmasters do is go white-list their own IP address so they don’t get blocked or banned mistakenly.

To white-list your own IP address, open the allow host file in the /etc/ directory and add your IP address you use to connect to the server.

sudo vi /etc/hosts.allow

Then add your IP address in the file and save it.

###############
####Example####
###############

sshd: 172.145.33.45

Restart DenyHosts by running the commands below.

sudo /etc/init.d/denyhosts start

DenyHosts configuration file is at /etc/denyhosts.conf.