- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- deactivate new users if NOT accessed the system - ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2004 09:37 AM
06-08-2004 09:37 AM
I would like to limit this to NEW users only, any sugetions?
you have to copy the /etc/passwd file to control location which is re-created after the script is run.
I was thinking this could be initiated via crontab once every 24 hrs...
All input is appreciated,
manuel contreras
#!/bin/sh
#this script will check for new users and deactivate accounts
#if users have NOT accessed the system in Xnumber of days.
diff /etc/passwd /usr/local/unix/Security/passwd.copy | grep "<" | egrep -v 'root:' > \
/usr/local/unix/Security/passwd.diff
awk -F: '{print $1, $6}' /usr/local/unix/Security/passwd.diff | awk '{print $2, $3}' > \
/usr/local/unix/Security/newUSERS.lst
currentD=`date '+%d %e'`
for x in `cat /usr/local/unix/Security/newUSERS.lst | awk '{print $1}'`
do
usrHOME=`grep $x /usr/local/unix/Security/newUSERS.lst | awk '{print $2}'`
echo "$usrHOME will be checked"
usrHIST=`find "$usrHOME"/.sh_history -mtime +3 -print`
echo "$userHIST"
if [ -n "$usrHIST" ]
then
echo "today is - $currentD "
echo "the user was created more than 3days ago - today is $currentD "
echo""
echo "now checking If user has logged on the system"
userSTAT=`last -1 $x | grep begins `
if [ -n "$userSTAT" ]
then
echo "user will be deactivated"
echo "/usr/sam/lbin/usermod.sam -p "*" $x "
echo""
fi
else
echo "user has accessed the system recently"
fi
done
cp /etc/passwd /usr/local/unix/Security/passwd.copy
exit
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2004 09:38 AM
06-08-2004 09:38 AM
Re: deactivate new users if NOT accessed the system - NON trusted
manuel contreras
echo "/usr/sam/lbin/usermod.sam -p "*" $x "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2004 10:16 AM
06-08-2004 10:16 AM
SolutionIf I understand your script correctly,
You are taking a difference of passwd.copy and the current passwd file and arriving at the new users. Say a user 'user1' got created just before you ran this script. That user would automatically become 'old' with the command 'cp /etc/passwd /usr/local/unix/Security/passwd.copy'. So, you would need to incorporate further logic to retain the new users until 3 days. I would maintain four files - as newusers.now, newusers.1dayold, newusers.2dayold, newusers.3dayold. Everytime the script is run, it checks for each user in all these files and takes the users out of the files if the activity was found. The users left in newusers.3dayold file will be appended to newusers.disabled file and newusers.2dayold will be moved as newusers.3dayold etc.,
Also," grep $x /usr/local/unix/Security/newUSERS.lst | awk '{print $2}'" may not work always. For ex., users user1 and user11. So, add a delimiter like ":" or "," while you are making this user list.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2004 10:31 AM
06-08-2004 10:31 AM
Re: deactivate new users if NOT accessed the system - NON trusted
maybe I can have another job simply copy the /etc/passwd to control copy once a week, and take this out of the deactiveCHECKER?
thanks,
manuel contreras
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2004 10:34 AM
06-08-2004 10:34 AM
Re: deactivate new users if NOT accessed the system - NON trusted
The danger with simple grep is that it will give output for partial matching on a word and in case of users, it could be costly. for eg,
# grep smith newUSERS.lst
smith
smithj
smithjo
where as
#grep -w smith newUSERS.lst, would only give,
smith
This is from experience, and you may want to consider either doig more checks, or using ggrep to do exact word matching in case of usernames.
HTH,
Abdul.