Operating System - HP-UX
1758656 Members
2077 Online
108874 Solutions
New Discussion юеВ

Limit amount of logins per user

 
SOLVED
Go to solution
Jody Bennett
Advisor

Limit amount of logins per user

What limits the amount of logins per user?
"Sometimes you have to jump more than one fence to get out of the pasture."
7 REPLIES 7
Richard Darling
Trusted Contributor

Re: Limit amount of logins per user

Jody,
There are two kernel parameters that might be creating problem for you:

nstrtel - number of opened telnet sessions

npty - number of pseudoterminal

Richard
rdarling@southwickclothing.com
Richard Darling
Trusted Contributor

Re: Limit amount of logins per user

Jody, sorry - I didn't read your posting properly - not sure how you do that per user...
Richard
rdarling@southwickclothing.com
Vincenzo Restuccia
Honored Contributor

Re: Limit amount of logins per user

nstrtel
nstrtel specifies the number of telnet device files that the kernel can support for incoming telnet sessions.


Acceptable Values:
Minimum
60
Maximum
Default
60

npty specifies the maximum number of pseudo-tty data structures that are available on the system.

Acceptable Values:
Minimum
1
Maximum
Memory limited
Default
60


A user 60 logins.

Patrick Wallek
Honored Contributor
Solution

Re: Limit amount of logins per user

Jody,

I don't thinkthere is a way to limit the number of times a user can log on to the system. Something you could possibly do is add something a one of the users . files or the /etc/profile or something that when they login, it counts the number of times they are already logged in, and if they exceed that number, it doesn't let them log in.

Something like this may work:

user=`echo $LOGNAME`
user_count=`who | grep $user | wc -l`
if ( $user_count > 2 ) then
echo "You have exceeded the max number of logins allowed
exit
fi

I can't guarantee that the syntax is absolutely correct, but you get the idea.
A. Clay Stephenson
Acclaimed Contributor

Re: Limit amount of logins per user

Hi Jody,

Patrick is correct there is no way to limit the logins per user. You could make the entries in the .profiles that he suggests but ,of course, your users could easily edit them and thus out bushwhack you. You could also
do the changes in /etc/profile which should only be writable by root; but, be very careful that nothing you do alters non-regular users (e.g. root).

The one time I had to do this for real, I had to code a c replacement for login. Fortunately, there were no graphical logins or a dtlogin replacement would have also been required. This is not an execise for the faint of heart but it is doable.

Regards, Clay
If it ain't broke, I can fix that.
Greg Conn
Advisor

Re: Limit amount of logins per user

Add this to /etc/profile.


# Check for multiple logins

if [ -x "/usr/bin/whoami" ]
then
WHOAMI=`whoami`

if [ "$WHOAMI" = "root" -o then
:
else

# if [ `who | grep ^$WHOAMI | wc -l` -gt 1 ]
if [ `who | grep -c "^$WHOAMI"` -gt 1 ]
then
echo "\n\n W A R N I N G !"
echo "\nYou can't log in now because someone is logged"
echo "in with this user ID. If you think that"
echo "someone is using your account, please contact"
echo "the Shift Manager immediately....\n\n"
sleep 20
exit 1
fi
fi
fi

######

You can add other whoami's.
Michael Tully
Honored Contributor

Re: Limit amount of logins per user

Hi Jody,

I had a similar problem a few years back and it
was solved by adding a login step. This entailed
creating a script in between /etc/profile and
$HOME/.profile. I have attached a copy of it
for you. The script checked to see what class
of user you were before continuing or logging
you out.

HTH
Michael
Anyone for a Mutiny ?