Operating System - HP-UX
1825766 Members
2067 Online
109687 Solutions
New Discussion

Is there an easy way to limit concurrent login sessions?

 
Peter Floyd_1
Occasional Contributor

Is there an easy way to limit concurrent login sessions?

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.
8 REPLIES 8
Charles Guiocheau
Occasional Advisor

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

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
R Madhavan_1
New Member

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

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.
Javier Juarez_2
Occasional Advisor

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

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.
PC_7
Frequent Advisor

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

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
Honored Contributor

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

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
Acclaimed Contributor

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

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.
If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

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

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

Pete
Anshumali
Esteemed Contributor

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

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.
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!