Skip to content

Instantly share code, notes, and snippets.

@yuan3y
Created April 11, 2021 08:55
Show Gist options
  • Save yuan3y/1b3d1469af70703dfb8ba3380401ea36 to your computer and use it in GitHub Desktop.
Save yuan3y/1b3d1469af70703dfb8ba3380401ea36 to your computer and use it in GitHub Desktop.
unban an IP from denyhosts
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo -e "Error:\n\tProvide IP as the first param"
echo -e "Usage:\n\t$0 <IP>"
exit 1
fi
/etc/init.d/denyhosts stop
echo '
/var/lib/denyhosts/hosts
/var/lib/denyhosts/hosts-restricted
/var/lib/denyhosts/hosts-root
/var/lib/denyhosts/hosts-valid
/var/lib/denyhosts/users-hosts
/etc/hosts.deny
' | grep -v "^$" | xargs sed -i "/$1/d"
/etc/init.d/denyhosts start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment