Skip to content

Instantly share code, notes, and snippets.

@stevejenkins
Created April 1, 2013 22:50
Show Gist options
  • Select an option

  • Save stevejenkins/5288434 to your computer and use it in GitHub Desktop.

Select an option

Save stevejenkins/5288434 to your computer and use it in GitHub Desktop.
Script for automatically unbanning/removing IPs and hostnames that were banned by DenyHosts. Courtesy of Cybernitus (http://www.cybertinus.nl/).
#!/bin/bash
#################
# CONFIGURATION #
#################
# The $WORK_DIR as set in /etc/denyhosts.conf. You can let this script find the
# setting automatically, or you can set it yourself.
DENYHOSTS_WORK_DIR=$(grep 'WORK_DIR' /etc/denyhosts.conf | grep -v '#' | cut -d '=' -f 2 | sed 's/ //')
#DENYHOSTS_WORK_DIR="/var/lib/denyhosts"
# All the files that contain the blocked IP address and hostname
DENYHOSTS_FILES=(\
'/etc/hosts.deny' \
"${DENYHOSTS_WORK_DIR}/hosts" \
"${DENYHOSTS_WORK_DIR}/hosts-restricted" \
"${DENYHOSTS_WORK_DIR}/hosts-root" \
"${DENYHOSTS_WORK_DIR}/hosts-valid" \
"${DENYHOSTS_WORK_DIR}/users-hosts" \
)
# The file containing the IP addresses and hostnames that can't be blocked
DENYHOSTS_ALLOWED_FILE="${DENYHOSTS_WORK_DIR}/allowed-hosts"
# The command needed to start denyhosts after the IP and/or hostname is unbanned
START_COMMAND='/etc/init.d/denyhosts start'
# The command needed to stop denyhosts before the IP and/or hostname is unbanned
STOP_COMMAND='/etc/init.d/denyhosts stop'
#############################################
# ACTUAL SCRIPT do not edit below this line #
#############################################
# set some default values to a few vars used in the script
# Don't remove an IP address (N=remove, Y=don't remove)
NO_IP='N'
# Don't remove an hostname (N=remove, Y=don't remove)
NO_HOST='N'
# Add the IP address and/or hostname to the allowed list
ADD_ALLOW='N'
# The IP address that has to be removed
IP=''
# The hostname that has to be removed
HOST=''
function show_help()
{
echo $0
echo "a small script to unblock an IP address and/or hostname from denyhosts.
-h | --host | --hostname : Specify the hostname to unblock (required, unless -nh is added).
-i | --ip | --ipaddress : Specify the IP address to unblock (required, unless -ni is added).
-nh | --no-host | --no-hostname : Don't require a hostname to start unblocking things.
-ni | --no-ip | --no-ipaddress : Don't require an IP address to start unblocking things.
-a | --add | --add-allow : Add the specified IP address and/or hostname to the unblock file, thus preventing that the specified IP address and/or hostname get blocked again.
-H | --help : show this help."
}
# Handle the commandline options
while [ -n "$(echo $1 | grep -- '-')" -a $# -gt 0 ]; do
case $1 in
-h | --host | --hostname) HOST=$2; shift 2;;
-i | --ip | --ipaddress) IP=$2; shift 2;;
-nh | --no-host | --no-hostname) NO_HOST='Y'; shift;;
-ni | --no-ip | --no-ipaddress) NO_IP='Y'; shift;;
-a | --add | --add-allow) ADD_ALLOW='Y'; shift;;
*)
echo "Unknown argument $1" 1>&2
echo ''
show_help $0
exit 1
;;
esac
done
# Checks to see if the required IP address and/or hostname are given
if [ "${NO_IP}" == 'N' -a "${IP}" == '' ]; then
echo 'No IP address given, exiting now' 1>&2
exit 1
fi
if [ "${NO_HOST}" == 'N' -a "${HOST}" == '' ]; then
echo 'No hostname given, exiting now' 1>&2
exit 2
fi
# Show warnings if removing of an IP address and/or hostname is disabled
if [ "${NO_IP}" == 'Y' ]; then
echo 'WARNING: You disabled removing an IP address. Most bans consist of both an IP address and a hostname. Please double check if you want this. Continuing now.' 1>&2
fi
if [ "${NO_HOST}" == 'Y' ]; then
echo 'WARNING: You disabled removing a hostname. Most bans consist of both an IP address and a hostname. Please double check if you want this. Continuing now.' 1>&2
fi
# Stopping denyhosts
${STOP_COMMAND}
# Loop through all the denyhost files, to remove the IP address and/or hostname
for FILE in ${DENYHOSTS_FILES[@]}; do
# Check to see if the current denyhosts file exists, is a normal file, is
# readable and is writable
if [ -f "${FILE}" -a -r "${FILE}" -a -w "${FILE}" ] ; then
# Check to see if there is an IP address to remove
if [ "${NO_IP}" = 'N' ] ; then
# Check that the IP address exists in the current denyhosts file
if grep -q "${IP}" "${FILE}" ; then
# Remove the IP address from the current denyhosts file
sed -i "/${IP}/d" "${FILE}"
echo "Removed ip address ${IP} from ${FILE}"
else
# The IP address doesn't exists in the current denyhosts file,
# notify user
echo "The ip address ${IP} wasn't in ${FILE}"
fi
fi
# Check to see if there is a hostname to remove
if [ "${NO_HOST}" = 'N' ] ; then
# Check that the hostname exists in the current denyhosts file
if grep -q "${HOST}" "${FILE}" ; then
# Remove the hostname from the current denyhosts file
sed -i "/${HOST}/d" "${FILE}"
echo "Removed hostname ${HOST} from ${FILE}"
else
# The hostname doesn't exists in the current denyhosts file,
# notify user
echo "The hostname ${HOST} wasn't in ${FILE}"
fi
fi
fi
done
# Check to see if the IP address and/or hostname needs to be added to the
# allowed-hosts file
if [ ${ADD_ALLOW} = 'Y' ] ; then
# Check to see if there is an IP address to add
if [ "${NO_IP}" = 'N' ] ; then
echo "${IP}" >> "${DENYHOSTS_ALLOWED_FILE}"
fi
# Check to see if there is a hostname to add
if [ "${NO_HOST}" = 'Y' ] ; then
echo "${HOST}" >> "${DENYHOSTS_ALLOWED_FILE}"
fi
fi
# Start denyhosts again
${START_COMMAND}
@dk8325294-rgb

Copy link
Copy Markdown

ar BGMI Team,
I am writing to appeal the 10 years ban recently imposed on my BGMI account (Account ID:51365136248) This severe penalty has left me baffled and deeply concerned. I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 10 years ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community. investment I've put into this account. I am willing to cooperate fully to resolve this issue promptly. Your swift attention to this matter is greatly appreciated. I look forward to your response.
Sincerely,
Account ID:51365136248

@dk8325294-rgb

Copy link
Copy Markdown

ar BGMI Team, I am writing to appeal the 10 years ban recently imposed on my BGMI account (Account ID:51365136248) This severe penalty has left me baffled and deeply concerned. I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 10 years ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community. investment I've put into this account. I am willing to cooperate fully to resolve this issue promptly. Your swift attention to this matter is greatly appreciated. I look forward to your response.Sincerely, Account ID:51365136248

@dk8325294-rgb

Copy link
Copy Markdown

ar BGMI Team, I am writing to appeal the 10 years ban recently imposed on my BGMI account (Account ID:51365136248) This severe penalty has left me baffled and deeply concerned. I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 10 years ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community. investment I've put into this account. I am willing to cooperate fully to resolve this issue promptly. Your swift attention to this matter is greatly appreciated. I look forward to your response.Sincerely, Account ID:51365136248

@ddgb844-jpg

Copy link
Copy Markdown

6 mahine Ho Gaya aapko message hoga please meri madad karo Sar Main Hun Koi hath nahin lagaya kitni bar batao id 55567064447
7845
5529
7845
5530
5531

@prabhumeshram134-stack

Copy link
Copy Markdown

Cvhnn

@karankakroliya-create

Copy link
Copy Markdown

Dear BGMI Team,
I am writing to appeal the 10-year ban recently imposed on my BGMI account (Account ID: 5269094681). This severe penalty has left me baffled and deeply concerned.
I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 7-day ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years.
I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community.
Please consider the years

@kshiv53128-bot

Copy link
Copy Markdown

55664082181
N¹・isLíve
Please my bgmi account unbanned

@kshiv53128-bot

Copy link
Copy Markdown

55664082181
N¹・isLíve
Please my bgmi account unbanned

@kshiv53128-bot

Copy link
Copy Markdown

Uploading 31939.jpg…

@kshiv53128-bot

Copy link
Copy Markdown

.

@kshiv53128-bot

Copy link
Copy Markdown

🙏

@kshiv53128-bot

Copy link
Copy Markdown

Bgmi unban

@katilkigadi-rgb

Copy link
Copy Markdown

Hello To The Respect Team Of Battleground mobile India

I never use any cheat and hack in my game i always play the game according to your term and conditions. following your all rules and regulations. yet you have banned my account for not any valid reason. I request you to unbanned my account and return my account to me as soon as possible

Id :5544402004

ld name 👎
5041

@katilkigadi-rgb

Copy link
Copy Markdown

Uploading 5041.jpg…

@katilkigadi-rgb

Copy link
Copy Markdown
<script src="https://gist.github.com/stevejenkins/5288434.js"></script>

@katilkigadi-rgb

Copy link
Copy Markdown

Hello To The Respect Team Of Battleground mobile India

I never use any cheat and hack in my game i always play the game according to your term and conditions. following your all rules and regulations. yet you have banned my account for not any valid reason. I request you to unbanned my account and return my account to me as soon as possible

Id :5544402004

ld name 🔢

@aji813505

Copy link
Copy Markdown

ar BGMI Team,
I am writing to appeal the 10 years ban recently imposed on my BGMI account (Account ID:55545340401) This severe penalty has left me baffled and deeply concerned. I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 10 years ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community. investment I've put into this account. I am willing to cooperate fully to resolve this issue promptly. Your swift attention to this matter is greatly appreciated. I look forward to your response.
Sincerely,
Account ID:55545340401

@aji813505

Copy link
Copy Markdown

12570
ar BGMI Team,
I am writing to appeal the 10 years ban recently imposed on my BGMI account (Account ID:55545340401) This severe penalty has left me baffled and deeply concerned. I have been a loyal and fair player for over 5 years, with a clean record. Just a month ago, I reported a hacker who received a mere 10 years ban. My account, with no history of wrongdoing, has been banned for an astonishing 10 years I implore you to investigate my account thoroughly and provide a clear reason for this extreme punishment. Restoring my account would not only mean a lot to me personally but also demonstrate your commitment to fair play in the BGMI community. investment I've put into this account. I am willing to cooperate fully to resolve this issue promptly. Your swift attention to this matter is greatly appreciated. I look forward to your response.
Sincerely,
Account ID:55545340401

@aji813505

Copy link
Copy Markdown

Please unban my bgmi id 🙏

@Surajb070

Copy link
Copy Markdown

Dear BGMI Customer Support Team,

Thank you for your response dated January 22, 2026. I escalate respectfully for senior review—this seems a false positive on my clean 8-year account (User ID: 5148641184, OnePlus 11, Android 15).

Proven Legitimacy:

  • 8 years loyal play, thousands of hours, no prior bans.
  • Elite rankings: Top 4000 this season, last season, and previous—pure skill.
  • Device verification: Please check my device logs—no cheats, hacks, macros, rooted/modded apps, or unauthorized software installed.

False Positive Cause: Office corporate VPN for work (shared IPs only). All BGMI on personal mobile data. Incident: Jan 21, 2026.

Per policy, request:

  1. Violation specifics (rule/timestamp).
  2. Manual review of device logs, top 4000 stats, and history.
  3. Unban for verified loyal player.

Attachments:

  • Top 4000 rank screenshots (multiple seasons).
  • Match history (8 years).
  • Gameplay video (mobile data).
  • VPN logs (work-only).

Ready to cooperate fully. Thank you.

Best regards,

@orgilbatsuur4-cyber

Copy link
Copy Markdown

Hello PUBG Support Team,

I hope you are doing well. I am writing to appeal a ban on my PUBG account.

• Username: StarCartain
• Player ID: 51835319582

My account has been banned, but I strongly believe this was a mistake. I have always followed the game rules and have never used any cheats, hacks, or third-party software.

I kindly ask you to review my account activity and reconsider this ban. If there has been any misunderstanding or false detection, I would really appreciate your help in resolving it.

PUBG is very important to me, and I have invested a lot of time into my account. I sincerely hope you can take another look at my case.

Please let me know if you need any additional information.

Thank you very much for your time and support.

Best regards,
StarCartain
5331
5331

@batoolmarrium-blip

Copy link
Copy Markdown

Dear PUBG Mobile Support Team,

I am writing to appeal the 10-year ban placed on my account (Player ID: 51432952825).

In-Game Name: 彡MuntazirDF彡

I respectfully believe this ban may have been issued in error. I have not knowingly used any cheats, hacks, or unauthorized third-party tools, and I have always aimed to follow the game’s rules and maintain fair gameplay.

I kindly request a detailed review of my account activity. If possible, please provide the specific reason for this ban so I can better understand the situation.

If any unusual or suspicious activity was detected, it may have been unintentional, and I would appreciate the opportunity to clarify.

I am willing to fully cooperate and provide any additional information required.

Thank you for your time and consideration.

Sincerely,
Muntazir
IMG_20260506_223359
IMG_20260506_223343

@mondalarnab377-a11y

Copy link
Copy Markdown

Dear BGMI Mobile Support Team,

I am writing to appeal the 10-year ban placed on my account (Player ID: 5373042614).

I respectfully believe this ban may have been issued in error. I have not knowingly used any cheats, hacks, or unauthorized third-party tools, and I have always aimed to follow the game’s rules and maintain fair gameplay.

I kindly request a detailed review of my account activity. If possible, please provide the specific reason for this ban so I can better understand the situation.

If any unusual or suspicious activity was detected, it may have been unintentional, and I would appreciate the opportunity to clarify.

I am willing to fully cooperate and provide any additional information required.

Thank you for your time and consideration.

Sincerely,
SUBRATA HANSDA
Uploading 1000051435.jpg…

@sharukkhan000000000-collab

Copy link
Copy Markdown

Hello BGMI Support Team,

My BGMI account has been banned for 10 years. I request a manual review of my account because I believe the ban may be incorrect.

Character ID: 51347466287
In-game Name: 戈Mr๛ABHÍツ
Ban Date: 23/05/2026

I have always tried to follow BGMI rules and request you to kindly review my account again.

Thank you.
Uploading 107410.jpg…

@rdxlover7318-spec

Copy link
Copy Markdown

Hi, you guys can help me how to unbanned bgmi account

Ha my bgmi account ban ho gya h unbaan karna hai please

@rdxlover7318-spec

Copy link
Copy Markdown
13997 My bgmi account ban

@stevethevendor-svg

Copy link
Copy Markdown

Hello CODM Support Team,

My CODM account has been banned for 10 years. I request a manual review of my account because I believe the ban may be incorrect.

Player ID: anon137807605928#9479927

I have always tried to follow CODM
Uploading 307067.jpg…
rules and request you to kindly review my account again.

Thank you.

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