account should be expired if not logged in for 15 days through FTP
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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?
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
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.
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.