- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Restricting users to one login session
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2001 11:04 PM
05-30-2001 11:04 PM
I was wondering if anyone could help me. I want to restrict certain users to one login session each. Any idea of how I would do that?
Thanks,
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2001 11:35 PM
05-30-2001 11:35 PM
SolutionYou'll need to vi .profile of that user. DO
this:
#limit number of of logins allowed
Time_allowed = 1
Time_in = "who | grep $LOGNAME | wc -1"
if [$Time_in -gt "$Time_allowed"]
then
echo "$LOGNAME is already logged in $Time_allowed times"
exit
exec /bin/login
fi
Then you'll have to chmod 444 and chown root .profile.
Hope this will help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2001 11:36 PM
05-30-2001 11:36 PM
Re: Restricting users to one login session
Add these lines to the .profile :
no_of_users=`ps -ef|grep $LOGNAME|grep -v grep |wc -l`
export no_of_users
#
if test "$no_of_users" -gt 3
then
tput clear
echo "You are already logged in more than once......"
echo "Number of: $LOGNAME user logged in: $no_of_users"
echo "exiting......"
sleep 2
exit 1
else
exec .....
fi
Rgds
Alexander M. Ermes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2001 11:39 PM
05-30-2001 11:39 PM
Re: Restricting users to one login session
last -R | grep -v grep |grep $USER | grep "still logged in"
if [ $? = 0 ]
then
exit
fi
The routine would go in individual users login scripts, or in /etc/profile with a case routine to identify users you don't want to have multiple logins (or you could perform it on a particular group by checking the $USER(s) GID in /etc/passwd ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2001 11:39 PM
05-30-2001 11:39 PM
Re: Restricting users to one login session
SOLUTION 1:
Heres a script to test for multiple logins, just call it from /etc/profile
nologin()
{
#nologin - test for user name already logged in
num=1
u=$LOGNAME
if [ "$u" = "
then
num=1
else
num=`who| cut -d" " -f1|grep "^$LOGNAME"$|wc -l`
fi
if [ $num -gt 1 ]
then
echo yours would be login number $num of name $LOGNAME
echo this is a big no-no!
echo please assign password to your login
echo if somebody else used your name, notify D.P. department
echo it is vital to the system\'s well being to know who the users are
echo it is with a heavy processor, that i have to deny you access.
echo have a nice day nevertheless - HAL very junior
exit
#else
# echo you are the one and only $LOGNAME - enjoy!
fi
}
SOLUTION 2:
"We use idled which works very well for both session limitations, multiple user viloations and idle limitations. You can obtain the source from ftp.cs.hope.edu in /pub/idled . This compiles just fine, and installs. This solution has idle limitations, or multiple user and session limitations, depending on which you want to use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 06:40 AM
05-31-2001 06:40 AM
Re: Restricting users to one login session
if (( $( who | grep -c $LOGNAME ) > 1 ) then
print "You [$LOGNAME] are currently logged into another session. You cannot log in to more than one session at a time. Please log out of the other session before you start another. "
exit 1
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 07:10 AM
05-31-2001 07:10 AM
Re: Restricting users to one login session
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 03:02 PM
06-01-2001 03:02 PM
Re: Restricting users to one login session
if [ -x "/usr/bin/whoami" ]
then
WHOAMI=`whoami`
if [ "$WHOAMI" = "root" -o "$WHOAMI" = "bogie" -o "$WHOAMI" = "haninged" -o "$WHOAMI" = "opc_op" -o "$WHOAMI" = "opc_ncc" -o "$WHOAMI" = "osborna" -o "$WHOAMI" = "greyson" ]
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2001 12:48 AM
06-02-2001 12:48 AM
Re: Restricting users to one login session
something to think about:
putting restrictions in the users .profile is not fullproof (/foolproof:). The user can allways change his .profile when he has write privileges in his home directory, even if file privileges are limited or the owner has been changed.
The way to go is through /etc/profile, but mind not to put restrictions for root or other system logins.
BTW I was allways able to surround limitations set up by sysadmins years ago when I was a programmer; so now as a sysadmin I now the tricks of the trade ;-).
regards,
Thierry