[SOLVED] Script year_month_day_hour_minute with fail2ban
Hello,
What I would like to do is a shell script which will read a database file, then it will compare the current date/hour/minute in each line existing in the database file.
Today is 20140305 (year_month_day) & assume that the time is 15:11 at the moment.
under /var/log/ database.txt
When the script is started it will create a new txt file such as:
under /var/log/ filtered.txt
Then it will look up related usernames in /var/log/syslog file, grep each user's ip address and send them to fail2ban to block the connection.
In this example, connection of usernames ssh2-ssh3-ssh4 will be broken.
I appreciate your valuable support.
PS: I have found given below iptables command but I do not know how to integrate this into my database file
-Objective: What I would like to accomplish is to terminate an account automatically if that account is expired.
-What does "then it will compare the current date/hour/minute in each line existing in the database file" mean?
When the script is started in any given time, it will print "system date" (year_month_day_hour_min) and compare the value shown in database.txt file
-Are you selecting records that are earlier than the current time?
That's exactly right!
-To make it more understandable, i changed database.txt file as shown below
under /var/log/
database.txt:
Output file will be filtered.txt as shown below:
sophie's account expired on 2014.03.01 time: 10:17
madonna's account expired on 2014.03.05 time: 09:00 (expired)
sophie.bextor & madonna has expired accounts so that those usernames will be looked up in /var/log/syslog file and the script will grab related ip addresses and send them to iptables so that they can not be logged in to the system.
Save perl script below to say "filter_accts.pl" and run it on the command line $ filter_accts.pl database.txt this will output all expired user accounts to filtered.txt...
Hello all,
I am facing a weird issue while executing a code below -
#!/bin/bash
cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset
sh UKBA_publish.sh UKBA 28082015 3
if
then
echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Hello, my fail2ban service is running (ps aux)
When i do:
fail2ban-client status
it returns:
ERROR Unable to contact server. Is it running?
same message on fail2ban restart.
In /etc/fail2ban/fail2ban.conf i see this line:
socket = /var/run/fail2ban/fail2ban.sock
but this file does... (1 Reply)
I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below.
#masterscript.sh
./callingscript.sh
echo $fileExist
#callingscript.sh
echo "The script is called"... (2 Replies)
Solved with iptables.
Many thanks...
Hello,
Objective:
What I would like to accomplish is :
- To read file1 line by line and search each word in file2.
- To grab corresponding ip addresses found in file2
- To send related ip addresses to fail2ban (not iptables)
By this way, when I... (5 Replies)
Hi all. I am using Cygwin in Windows 7 and am trying to setup fail2ban so that I can ban foreign IP addresses under SSH, also getting email notifications. I downloaded fail2ban and installed it. I then created jail.local copy from jail.conf and changed some values in jail.local. Now when I try to... (2 Replies)
I am using blow script :--
#!/bin/bash
FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not
if
then
# echo "process found"
exit 0;
else
echo "process not found"
exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Hi guys
I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file.
#!/bin/sh
echo " $2 $3 $4 $5 $6 $7
isql -w400 -U$2 -S$5 -P$3 << xxx
use $4
go
print"**Changes to the table... (0 Replies)