Skip to content

Instantly share code, notes, and snippets.

@jayjanssen
Created June 23, 2011 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jayjanssen/1043053 to your computer and use it in GitHub Desktop.
Save jayjanssen/1043053 to your computer and use it in GitHub Desktop.
denyhosts ip removal script
#!/bin/sh
HOST=$1
cd /var/lib/denyhosts
for i in `ls`; do mv $i $i.old; grep -v $HOST $i.old >> $i; done
cp /etc/hosts.deny /tmp/hosts.deny
grep -v $HOST /tmp/hosts.deny > /etc/hosts.deny
@jayjanssen
Copy link
Author

Nicked from http://www.cyberciti.biz/faq/linux-unix-delete-remove-ip-address-that-denyhosts-blocked/ and slightly modified. Add an /etc/init.d/denyhosts stop|start to the beginning and end respectively if you run denyhosts as a daemon.

@justforgetme
Copy link

Why do You have $HOST surrounded by ? @ line 6?
This code won't work for IPs with the questionmarks

@jayjanssen
Copy link
Author

Good question, must have been a copy-paste error or something. I noticed this in my private repository and fixed it this week, seems to work fine without the question marks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment