EnderUNIX Team.


EnderUNIX tips

Mail to My Friend , Home Page

[ Shell Scripting ]

"To make users to log in only once" - Omer Faruk Sen - (2007-09-01 11:58:43)   [6169]

There may be special system specific subsystems (for example pam) to make users to login system only once at the same time but currently there is none on Solaris 10

So I made following script add this to .profile of user

#--------------- start of script-----------------------------
ALLOWEDLOGINCOUNT=1
if test "$LOGNAME" != "root"
then
CURRENTLOGINCOUNT=`who | grep ${LOGNAME} |wc -l`
echo CURRENT logged in user including this session: ${CURRENTLOGINCOUNT}
echo ALLOWED login count: ${ALLOWEDLOGINCOUNT}


if [ "${CURRENTLOGINCOUNT}" -gt "${ALLOWEDLOGINCOUNT}" ]
then
exit "$1 is already logged on at $2"
fi
fi
#------------- end of script-----------------------------------

and

# chown root .profile
# chmod 754 .profile

So if user telnet from one session he/she can't login using telnet/ssh or X




Mail to My Friend , Home Page