Block User accounts who has not logged in to the server last 2 months
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
Block User accounts who has not logged in to the server last 2 months
Hi,
We have 4 servers having rhel 5.2. We have several users logged in on one of them. We have nis server/client running on them and have common home area mounted on all of them.
Now we want to disable/block the accounts of the users who have not accessed our servers in last 2 months from today.
What logic should we apply to do so? We were checking stat of .bashrc of each user but is not correct logic.
We are going to write shell script for the same.
Any help would be appreciated.
W dont want to do anything in users home area or their files.
Looking at .bashrc doesn't sound reliable. Presumably you back up user's home directories and that would probably access their .bashrc.
Assuming you have centralised authentication (you mention NIS but don't say what you're using it for), I'd probably start by looking at the logs on the authentication server.
I suspect that wouldn't work because the users are managed centrally rather than existing on each machine. Even if that isn't the case, it wouldn't work because usermod needs to be run by root. Also, what pvs said. (Such a command should be placed in to /etc/bash.bashrc or equivalent anyway so as to avoid the need to modify lots of .bashrc files and to avoid the scenario pvs mentions.)
The OP mentioned NIS, which can be used to manage accounts centrally. Though the OP has not bothered to clarify whether or not this is what they are doing or whether they're using NIS for authentication.
Quote:
Originally Posted by aksharb
it is not samba managed. Kindly provide us any robust logic/idea.
Hey, you know your set up, you're in the best position to figure it out. If you can set all that stuff up, you should have a decent idea of how to figure out the solution yourselves.
Is authentication done against a central server? If so, see my previous reply. Otherwise you'll have to trawl the logs on each server. Look at the output of 'last' and if that doesn't go back far enough then try running last against the archived versions of /var/log/wtmp.
Authentication is done against nis and there is load balancing among these servers. I think i will have to look at "last" command output on each nis clients and check whether user has logged in or not.
But is there ant other logic that can be implemented?
Authentication is done against nis and there is load balancing among these servers. I think i will have to look at "last" command output on each nis clients and check whether user has logged in or not.
If authentication is happening against more than one NIS server, just look at the logs of all the servers.
Quote:
Originally Posted by aksharb
But is there ant other logic that can be implemented?
Well you can look at logs on the servers or you can look at logs on the clients. I can't think of any other way of finding the information.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.