Skip to content

Instantly share code, notes, and snippets.

@hydrz
Created May 29, 2021 04:21
Show Gist options
  • Save hydrz/425b91b4779c8ed3a1cd949ea9fc6fbd to your computer and use it in GitHub Desktop.
Save hydrz/425b91b4779c8ed3a1cd949ea9fc6fbd to your computer and use it in GitHub Desktop.
denyhosts_removeip
#!/bin/bash
# Author:licess
# Website:https://www.vpser.net & https://lnmp.org
HOST=$1
if [ -z "${HOST}" ]; then
echo "Usage:$0 IP"
exit 1
fi
echo "Remove IP:${HOST} from denyhosts..."
/etc/init.d/denyhosts stop
echo '
/etc/hosts.deny
/usr/share/denyhosts/data/hosts
/usr/share/denyhosts/data/hosts-restricted
/usr/share/denyhosts/data/hosts-root
/usr/share/denyhosts/data/hosts-valid
/usr/share/denyhosts/data/users-hosts
' | grep -v "^$" | xargs sed -i "/${HOST}/d"
#iptables -D INPUT -s ${HOST} -p tcp -m tcp --dport 22 -j DROP
echo " done"
/etc/init.d/denyhosts start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment