Sponsored Content
Top Forums Shell Programming and Scripting Script year_month_day_hour_minute with fail2ban Post 302891477 by baris35 on Thursday 6th of March 2014 04:25:25 AM
Old 03-06-2014
Hello Blackrageous,

-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:

Code:
sophie.bextor ##201403011017
dido ##201403251049
ray.charles ##201403290159
freddie.mercury ##201404012200
madonna ##201403050900

Output file will be filtered.txt as shown below:

Code:
sophie.bextor ##201403011017
madonna ##201403050900

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.

Thanks for your time
Boris
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

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)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

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)
Discussion started by: ketanraut
1 Replies

3. Windows & DOS: Issues & Discussions

Fail2ban: email notifications and banning ssh IP logins

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)
Discussion started by: synthesis
2 Replies

4. Shell Programming and Scripting

Read file, grab ip with fail2ban

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)
Discussion started by: baris35
5 Replies

5. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

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)
Discussion started by: Raj Roy
2 Replies

6. Cybersecurity

Fail2ban ERROR Unable to contact server. Is it running?

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)
Discussion started by: postcd
1 Replies

7. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

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)
Discussion started by: ektubbe
2 Replies
pam_sm_acct_mgmt(3)					     Library Functions Manual					       pam_sm_acct_mgmt(3)

NAME
pam_sm_acct_mgmt() - service provider implementation for pam_acct_mgmt SYNOPSIS
[flag]... file... [library]... DESCRIPTION
In response to a call to pam_acct_mgmt(3), the PAM framework calls from the modules listed in the pam.conf(4) file. The account management provider supplies the back-end functionality for this interface function. The applications should not call this API directly. The function, determines whether the current user's account and password are valid. This includes checking for password and account expi- ration, valid log-in times, etc. The user in question is specified by a prior call to and is referenced by the authentication handle, pamh, which is passed as the first argument to The following flags may be set in the flags field: The account management service should not generate any messages. The account management service should return if the user has a null authentication token. The argc argument represents the number of module options passed in from the configuration file pam.conf(4). argv specifies the module options, which are interpreted and processed by the account management service. Please refer to the specific module man pages for the var- ious available options. If an unknown option is passed to the module, an error should be logged through syslog(3C) and the option ignored. If an account management module determines that the user password has aged or expired, it should save this information as state in the authentication handle, pamh, using uses this information to determine which passwords have expired. APPLICATION USAGE
Refer to pam(3) for information on thread-safety of PAM interfaces. RETURN VALUE
If there are no restrictions to logging in, is returned. The following error values may also be returned upon error: User not known to underlying authentication module. New authentication token required. User account has expired. User denied access to account at this time. Ignore underlying account module regardless of whether the control flag is or User account has been disabled (trusted mode only). Terminal has been disabled (trusted mode only). User is not authorized for terminal access (trusted mode only). Wrong time to login (trusted mode only). WARNINGS
HP-UX 11i Version 3 is the last release to support trusted systems functionality. SEE ALSO
pam(3), pam_acct_mgmt(3), syslog(3C), pam.conf(4). pam_sm_acct_mgmt(3)
All times are GMT -4. The time now is 01:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy