Jest jakieś rozwiązanie które nie zablokuje dostępu do strony tylko zablokuje dostęp do shh ?
Znalałem coś takiego jak poniżej, lecz poniższy skrypt ma jak dla mnie kilka wad.
1 Skrypt poniżej bedzie mi blokował dostęp dla danego ip do całej strony, a nie tylko ssh no i
2 Wolałbym aby blokowało to tylko dane ip na jakiś czas a nie na zawsze ( a co bedzie jak będę miał stałe ip i pomylę się te kilka razy )
3 Czy skanowanie za pomoca wyrazeń regularnych logów co np minute logów nie spowoduje, wiekszego obciązenia ?
Może ma ktoś jakieś inne rozwiązania tego problemu (juz napisane
#!/bin/bash
LAST_IP=0.0.0.0
COUNT=1
# Set MAXCOUNT to the maximum failures allowed before blacklisting
MAXCOUNT=5
#
# The three lines below put the leading lines in /etc/hosts.allow
# Note: This script overwrites the entire /etc/hosts.allow file.
#
echo '
# /etc/hosts.deny
# See "man tcpd" and "man 5 hosts_access" as well as /etc/hosts.allow
# for a detailed description.
http-rman : ALL EXCEPT LOCAL' > /etc/hosts.deny
#
# Scan the /var/log/messages file for failed login attempts via ssh.
# Parse out the IP address, and count the failure occurances from that IP
# If the IP fails more than 5 times - deny further access
#
for IP in `/bin/grep sshd /var/log/messages|/bin/grep "Illegal user"|/bin/sed 's/^.*from :*[a-z]*://'` 0.0.0.0; do
if [ ${LAST_IP} == ${IP} ]; then
let COUNT=${COUNT}+1
else
if [ ${COUNT} -ge ${MAXCOUNT} ]; then
echo "ALL: ${LAST_IP}/32" >> /etc/hosts.deny
fi
LAST_IP=${IP}
COUNT=1
fi
done