I want to create an user account which the password will be valid for 1 session only. After the session, the password for the account will be expired and the account will be disabled.
Is there any way for me to do this? Thank you.
If this is only for a short period of time, or say it is only for a person that will be there for a day or so, can't you just create it and then delete it when they leave, or you don't need the name anymore?
I have to setup an account for a remote user from another country to access to my server. Whenever the remote user want to access to my server, I will give him the new password for the account and after he finish accessing my server and logout, I want the account automatically disable so that outsiders cannot access my server using this account anymore. Whenever the user want to access it, I'll then just create a new password for the user to access it.
Is there anyway for me to setup the account like this? Thank you.
I've already tried the expired date for the useradd but I found this not very practical as I don't know when the user need to access to my server. The user only need to access when he needs to debug his program on the server.
#! /bin/ksh
# lock an account upon logout
# Run as a root cronjob x times an hour
# File with users to monitor
USERS=/var/tmp/users.dat
for EACHUSER in $(< $USERS) ; do
# Check if the user was just logged in
if [[ -f /var/tmp/.$EACHUSER.flag ]] ; then
if who | grep $EACHUSER > /dev/null ; then
# Do nothing if still logged in
:
else
# The user is no longer logged in
# lock the account and remove the flag file
passwd -l $EACHUSER
rm /var/tmp/.$EACHUSER.flag
fi
fi
if who | grep $EACHUSER > /dev/null ; then
# Set the flag file if logged in
touch /var/tmp/.$EACHUSER.flag
fi
Thanks for the script as it work as what I need. Thank you very much for your help and your time.
Hi J1mbo,
I've tried your script but I encounter some syntax error with your script. I'm not very good in Unix scripting, so I'm still trying to figure out way to correct your script so that it can works. Anyway, thank you very much for providing me with the script and for your time.
You two really help me alot in solving my problem.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.