Score:0

banning IPs from file in Fail2ban

vc flag

I've installed fail2ban and it's working fine in banning IPs that try to access ssh with invalid username/password even if they tried once.

Now I'm receiving key exchange attacks that fail2ban doesn't deal with in the default setup.

I created cron that generate the IPs using the command:

sudo cat /var/log/auth.log | grep "Unable to negotiate" | awk '{print $10}' |sort |uniq >> ipsfile

Now I want to add these IPs to fail2ban so I can control the ban in one location rather than splitting the work between IPTables and fail2ban.

I wrote a simple bash:

for IP in $(cat ipsfile); do echo "banning $IP"; sudo fail2ban-client set sshd banip $IP;done

How to make this actually efficient without duplicates?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.