Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Forked from jayjanssen/denyhosts-remove-ip.sh
Last active December 27, 2015 12:19
Show Gist options
  • Save carymrobbins/7324814 to your computer and use it in GitHub Desktop.
Save carymrobbins/7324814 to your computer and use it in GitHub Desktop.
#!/bin/bash
HOST=$1
if [ -z "$HOST" ]; then
echo "Enter host IP:"
read HOST
fi
sudo service denyhosts stop
cd /var/lib/denyhosts
for i in $(ls)
do
sudo mv $i $i.old
sudo grep -v $HOST $i.old >> $i
done
sudo cp /etc/hosts.deny /tmp/hosts.deny
sudo grep -v $HOST /tmp/hosts.deny > /etc/hosts.deny
sudo service denyhosts start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment