Find out or start to log last login of all ftp users
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.
Find out or start to log last login of all ftp users
I have an old RHEL vsftp server that has quite a few user accounts that i'm guessing aren't used and haven't been used in some time. Is there a "last login" somewhere that i can list for all the accounts in /etc/passwd or a way i can start logging each users last login so i can check it again in say a few months to see who hasn't even logged in?
Are these virtual users or do they have actual accounts on the system? How far back do your /var/log/{ftp,vsftp,secure} logs go? How about the mtime of distinctive files owned by respective users?
They're "real" users who show up in /etc/passwd. Looks like my oldest log in /var/log is a .4 from August 11th.
the mtime thing sounds very clever, but I don't know if that would work for all users, as some of the accounts just upload a file that is plucked away within minutes by another process as it's input. Plus i'm not sure how I could generate a report by account like that haha. but it does sound VERY cool.
Looks like my oldest log in /var/log is a .4 from August 11th.
Default log retention (or rather not giving thought to changing defaults) seems to mar a lot of hosts.
Quote:
Originally Posted by rjo98
They're "real" users who show up in /etc/passwd.
Then let's assert they're in /var/log/wtmp as well? (As in 'man last'.)
Quote:
Originally Posted by rjo98
the mtime thing sounds very clever, but I don't know if that would work for all users, as some of the accounts just upload a file that is plucked away within minutes by another process as it's input. Plus i'm not sure how I could generate a report by account like that haha. but it does sound VERY cool.
Well it was just an idea. You could generate a list like this:
Code:
#!/bin/bash --
# For testing:
# set -vx
# Sane defaults:
LANG=C; LC_ALL=C; export LANG LC_ALL; umask 0027
# Get list of users, here any UID of 500 and over
# (value actually is 'awk '/^UID_MIN/ {print $2}' /etc/login.defs;':)
awk -F ':' '{if ($3 >= 500) print $1,$3}' /etc/passwd | while read _LOGNAME _UID; do
# Echo resolved account name and display latest wtmp entry:
echo "${_LOGNAME}: $(last -wai|grep -m1 "${_LOGNAME}")";
# Find files (change "/path/to/ftproot") by UID, print epoch and file name, then sort:
find /path/to/ftproot -user ${_UID} -maxdepth 10 -printf "%T@ %p\n"|sort -nk1
# * Note UID, level restriction and epoch are for speeding up things.
# Separate between users:
echo
done
exit 0
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.