LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-03-2013, 05:01 PM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
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?
 
Old 09-03-2013, 06:03 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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?
 
Old 09-04-2013, 08:19 AM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
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.
 
Old 09-04-2013, 05:39 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by rjo98 View Post
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 View Post
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 View Post
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
 
Old 09-05-2013, 09:02 AM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
If I just run a last, all i get are the users who actually ssh to the server, none of the ftp users.

When I run the script, it only returned something useful for my user account, the rest of them it just showed something like

nfsnobody:
find: /path/to: No such file or directory
 
  


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 vsftpd users last login time. dilipvp Linux - Newbie 1 03-10-2011 03:44 PM
Do FTP users must have a login shell? tanveer Linux - Server 12 11-14-2007 09:38 PM
/etc/shells Pure-ftpd what is the users? Unable to log on ftp.. almost000 Linux - Newbie 5 05-02-2007 01:23 PM
FTP Server Up and running... how do I hide ftp users from local login screen? joe1031 Mandriva 2 03-18-2005 04:24 PM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM

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

All times are GMT -5. The time now is 02:40 AM.

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