What is DenyHosts? DenyHosts is a script intended to be run by Linux system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).
Note: Please upload any changes to the config files you wish to share to this TWIKI!
ASSUMES Ubuntu/Debian
ASSUMES Ubuntu/Debian
Note: Change the email address to suite your system
#/bin/bash # # Install and configure denyhosts # EMAIL is Point of contact From address # - it only helps to "encode" who is responsible for the machine in any reports to root # denyhosts reports still goes to root # Unless either of # 1 - /etc/aliases forwards root # - or - # 2 /etc/denyhosts.conf "ADMIN_EMAIL =" is changed # Otherwise EMAIL=cs-rsg@cs.uwaterloo.ca #install denyhosts apt-get install denyhosts ALLOWED=/var/lib/denyhosts/allowed-hosts DENYCONF=/etc/denyhosts.conf DENYTMP=/tmp/$$.denyhosts.conf HOST=`hostname` # Clean up old files rm -f $DENYTMP $ALLOWED wget -nH -nd https://www.cs.uwaterloo.ca/twiki/pub/CF/DenyHosts/allowed-hosts -O $ALLOWED wget -nH -nd https://www.cs.uwaterloo.ca/twiki/pub/CF/DenyHosts/denyhosts.conf -O $DENYTMP # Edit denyhosts.conf file to customize report to include the hostname in the report cat $DENYTMP | \ sed -e "s/^SMTP_FROM.*$/SMTP_FROM = DenyHosts <$EMAIL>/" | sed -e "s/^SMTP_SUBJECT.*$/SMTP_SUBJECT = $HOST DenyHosts Report/" >$DENYCONF #Debug: list the changes echo =============================================== echo DenyHosts Changes to $HOST egrep '^SMTP_[FS]|^ADMIN_EMAIL' $DENYCONF echo /etc/aliases root entry grep "^root" /etc/aliases echo =============================================== rm -f $DENYTMP #restart the service service denyhosts restart
ASSUMES Ubuntu/Debian TARGETS!!!
SECURE_LOG = /var/log/secure SMTP_FROM = DenyHosts <cs-rsg@cs.uwaterloo.ca> SMTP_SUBJECT = gamay-admin.cs DenyHosts Report
If DenyHosts has added an IP to /etc/hosts.deny removing it from /etc/hosts.deny does not in itself correct the issue since DenyHosts keeps track of the attempts in the WORK_DIR files (/var/lib/denyhosts in Ubuntu) . In order to cleanse the address you will need to do the following:
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
allowed-hosts | r2 r1 | manage | 0.6 K | 2011-12-15 - 10:23 | MikeGore | |
![]() |
denyhosts.conf | r1 | manage | 20.4 K | 2011-12-12 - 16:52 | MikeGore | |
![]() |
send_denyhosts | r1 | manage | 2.7 K | 2011-12-15 - 10:48 | MikeGore |