LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-23-2011, 09:42 AM   #1
linux_beginer
LQ Newbie
 
Registered: Mar 2011
Posts: 24

Rep: Reputation: 0
account should be expired if not logged in for 15 days through FTP


!!!Hello Everybody!!!

We have one ftp server. Number of users are using it remotly.
My requirement is that suppose any user is not connecting to the server using FTP for 15 days then account should get expired/locked automatically. Is it possible?
 
Old 03-23-2011, 10:56 AM   #2
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 215

Rep: Reputation: 66
What ftp server are you using? The problem I see with this is you need some way to check if a user had been logged in, in the last 15 days.

I need to know what ftp server you are using to see if it logs when users log in. If it does you can write a script that will run every day to check the logs. If the user did not log in within you time limit then you can lock his account.

Questions:
1) What distro are you using? (red hat?)
2) What ftp server are you using? (vsftpd?)
3) Does your ftp server log when someone logs in?
 
Old 03-23-2011, 11:13 AM   #3
linux_beginer
LQ Newbie
 
Registered: Mar 2011
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by savona View Post
What ftp server are you using? The problem I see with this is you need some way to check if a user had been logged in, in the last 15 days.

I need to know what ftp server you are using to see if it logs when users log in. If it does you can write a script that will run every day to check the logs. If the user did not log in within you time limit then you can lock his account.

Questions:
1) What distro are you using? (red hat?)
2) What ftp server are you using? (vsftpd?)
3) Does your ftp server log when someone logs in?
Distro: RHEL 5.5
Server: vsftpd
FTP server generates logs (vsftpd.conf) when anybody login.
Thanx
 
Old 03-23-2011, 11:36 AM   #4
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 215

Rep: Reputation: 66
well I am by no means a great programmer/script writer. I am sure if you post this in the programming section it will get more responses by people who can create a efficient script.

The steps I would take (which would probably be ugly and clunky)

1) Roll the vsftpd logs every night at midnight using cron with a small script.

#!/bin/bash
# Move to log directory
cd /log/dir/
# Copy log to new dated file
cp vsftpd.log vsftp.log.`date +%m%d%Y`
#Empty log
cat /dev/null vsftpd.log

2) Create a clunky script to check the logs for the last 15 days for the username.

#!/bin/bash
#Look for username in last 15 log files
for i in `find /log/dir/ -mtime -15 vsftpd.log.*`
do
X=`grep <user> $i | wc -l`
if [ -z "$X" ]
echo "user has logged in $X times in last 15 days"
else
echo "user has not logged in for 15 days"
usermod -L <user>
fi
done




To all the people on this forum: Please feel free to poke fun at me, as long as you teach me something!

To original poster: This code has not been tested and may or may not work. Please be careful.

Last edited by savona; 03-23-2011 at 11:38 AM.
 
Old 03-23-2011, 11:40 AM   #5
cincindie
Member
 
Registered: Jul 2004
Location: Zinzinnati, OH
Distribution: RH, FC 1-6, F 7-21, Debian, LinuxPPC, Knoppix, Ubuntu, Yellow Dog
Posts: 176

Rep: Reputation: 31
I believe webmin (http://webmin.com) can do it. Server settings can be configured using a web browser.
 
Old 03-24-2011, 12:36 AM   #6
linux_beginer
LQ Newbie
 
Registered: Mar 2011
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by savona View Post
well I am by no means a great programmer/script writer. I am sure if you post this in the programming section it will get more responses by people who can create a efficient script.

The steps I would take (which would probably be ugly and clunky)

1) Roll the vsftpd logs every night at midnight using cron with a small script.

#!/bin/bash
# Move to log directory
cd /log/dir/
# Copy log to new dated file
cp vsftpd.log vsftp.log.`date +%m%d%Y`
#Empty log
cat /dev/null vsftpd.log

2) Create a clunky script to check the logs for the last 15 days for the username.

#!/bin/bash
#Look for username in last 15 log files
for i in `find /log/dir/ -mtime -15 vsftpd.log.*`
do
X=`grep <user> $i | wc -l`
if [ -z "$X" ]
echo "user has logged in $X times in last 15 days"
else
echo "user has not logged in for 15 days"
usermod -L <user>
fi
done




To all the people on this forum: Please feel free to poke fun at me, as long as you teach me something!

To original poster: This code has not been tested and may or may not work. Please be careful.

Thanx savona!!! At least I got the direction to think...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find expired account rakeshkranjan Linux - Newbie 1 10-22-2010 08:53 AM
user account got expired. Sunheer Linux - Newbie 6 02-21-2010 10:28 PM
root account expired The helpless one Linux - Newbie 4 03-11-2006 12:27 PM
user account expired ??? rahimzai Red Hat 3 10-10-2005 05:03 AM
Re-enable an expired account xcoach Linux - Newbie 0 04-16-2004 10:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration