Operating System - HP-UX
1825720 Members
2905 Online
109686 Solutions
New Discussion

Repost - Is there an easy way to limit concurrent login sessions?

 
Gary Cantwell
Honored Contributor

Repost - Is there an easy way to limit concurrent login sessions?

This is a repost of the corrupted thread linked here:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1113

I have recovered the replies to this thread that are not showing. I don't have exact timestamps, just dates. Hope this helps
Gary

*****************************

Original Question:

Peter Floyd

2000-01-05

I am in need of an easy way to limit the number of concurrent login session any
given user can have. If anyone knows, please respond to my email address and/or
post in this forum. Thank you.

*************************************

Charles Guiocheau
2000-01-06

Hello there,

In your /etc/profile add the following lines

USER=$(whoami)
NBCNX=`who -H | grep ${USER} | grep -v root | wc -l`

if [ ${NBCNX} -gt 2 ]
then
echo "MSG login restrited"
exit
fi

regards

*****************************

Javier Juarez
2000-01-06

another easy response for your question, add the next pharagraph in the file
/etc/profile

.
.
trap 1 2 3
if [ "$LOGNAME" != "root" ]
then
if [ `who -u | awk ?{ print $1}?|grep "$LOGNAME"
| wc -l ` -gt 1 ]
then
clear
echo "Number of Conecctions Exceeded"
echo "CONECTION REFUSED"
exit
fi
fi
.
.
.
.


Regards.

***************************

R Madhavan
2000-01-06


The easy way i can suggest is to write a few lines script which count for
number of $LOGNAME for that login id and exit if it is above your limit. Call
this script thro' /etc/profile.
Hope this helps you.

*********************************

Tan Pau Cen
2007-03-21

Hi there,

You can set NUMBER_OF_LOGINS_ALLOWED in /etc/default/security file.

$ man 4 security
...

NUMBER_OF_LOGINS_ALLOWED
This parameter controls the number of simultaneous logins allowed per user. This is applicable only for non-root users.

NUMBER_OF_LOGINS_ALLOWED=0 Any number of logins are allowed per user.
NUMBER_OF_LOGINS_ALLOWED=N N number of logins are allowed per user.

Default value: NUMBER_OF_LOGINS_ALLOWED=0
-----------

Hope this helps.

******************************

Biswajit Tripathy
2007-03-21

You could use IPFilter system firewall to
limit the number of telnet/ssh/rlogin sessions,
but it will only let you set the limit per IP address
and not per user. If a user is tied to a particular
IP address in your network, then IPFilter is
the quick and easy solution.

- Biswajit

***************************

A. Clay Stephenson
2007-03-21

By far, the easist method is to edit /etc/default/security (you may need to create this file) and add an entry:
NUMBER_OF_LOGINS_ALLOWED=n.

Man security for details.

*****************************
Pete Randall
2007-03-21

Do a man on security, then set up a file called /etc/default/security with the NUMBER_OF_LOGINS parameter specified per your requirements.


Pete

******************************

Anshumali
2007-03-22

I am not sure of any inbuilt way of HP-UX to prevent a user from logging in more than one session concurrently. What i will do is, add the below lines into /etc/profile to check if the user is already logged in and if thats the case, don't let them log in again. Like...

LOGIN_SESS=`who | grep $LOGNAME | wc -l`
if ( $LOGIN_SESS >= 1 )
then
echo "You are already logged on this system."
echo "No more sessions allowed."
exit
fi

User can always modify it though.

*******************************




1 REPLY 1
Laurent Menase
Honored Contributor

Re: Repost - Is there an easy way to limit concurrent login sessions?

I see an other way writing a simple PAM module.