- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: limit user login
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
Discussions
Discussions
Forums
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
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
тАО07-08-2002 07:32 AM
тАО07-08-2002 07:32 AM
we use Baan ERP on UX11.00. Each login (on Baan) generate one user process (called bshell). From Baan, we can't limit number of user login for specific user.
We can try to limit number of user login, limiting number of bshell process that exist on UNIX.
How can I limit number of user login using - for example - script shell?
Thanx.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2002 07:40 AM
тАО07-08-2002 07:40 AM
Re: limit user login
I then added the following to a seperate profile called by the initial login profile.
USER=$(whoami)
echo $USER|egrep -q '(informix|dba)'
if [ ! $? -eq 0 ]
then
trap "exec exit" INT
TMPLOG=/tmp/login_limit.tmp
DATE=$(date)
LIMIT=$(grep ^$USER: /etc/passwd|cut -d":" -f5|cut -d"," -f4)
COUNT=$(ps -fu"$USER"|grep "$USER"|grep "\-ksh"|grep -v grep|wc -l)
if [ $LIMIT -o $LIMIT -ne 0 ]
then
if [ $COUNT -gt $LIMIT ]
then
echo "Sorry you are only allowed $LIMIT session(s) - Press Enter \c"
read NOTHING
echo "$DATE - $USER with $COUNT shells active tried to exceed $LIMIT ses
sions" >> $TMPLOG
ps -fu"$USER"|grep "$USER"|grep -v grep >> $TMPLOG
exit
fi
fi
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2002 07:43 AM
тАО07-08-2002 07:43 AM
Re: limit user login
Put the following code in /etc/profile(at the end)
user_name=`who -u |grep "your_user_name"`
if [$LOGNAME = $user_name]
exit 0
fi
What I am doing with above code is checking exisinting login and if it matches with incming login it will logout.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2002 07:52 AM
тАО07-08-2002 07:52 AM
Re: limit user login
The users don't execute /etc/profile or .profile.
The users connect on Baan from WIN95 clients that connect to Baan on Unix and in it, check the /etc/passwd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2002 08:04 AM
тАО07-08-2002 08:04 AM
Re: limit user login
This is what can be done:
edit /etc/profile
and put this lines in there:
loginid=`who am i | awk '{print $1}'`
export B=`who | grep loginid | wc -l`
if [ $B -gt 5 ]
then
exit
fi
this will allow only 5 users to login with that id.
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2002 08:11 AM
тАО07-08-2002 08:11 AM
Solutionbann_count=`ps -ef|grep [b]shell|awk '{print $2}'`
bann_count2=ps -ef|grep [b]shell|awk '{print $2}'` > /tmp/bann.test
kill -15 `cat /tmp/bann.test|grep -v $bann_count`
sleep 5
done
Keep the above code in a file and keep it running.
This puts the pid of first bshell in a variable and then keeps on checking if other bshells are coming and if gets it puts pids in file and finally kills all bshells except the first one-saved in bann_count variable.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2005 08:25 PM
тАО06-29-2005 08:25 PM
Re: limit user login
I trying used your scripts and put in to /etc/profile at last line .And I try login again ,giving a syntax error .
You have mail.
/etc/profile[132]:Syntax error:`&' is not expected .
Please advice me how to slove it
Thanks
Leongko
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-30-2005 12:02 AM
тАО06-30-2005 12:02 AM
Re: limit user login
MAX_LOGIN=5
if [[ $(who | grep $LOGNAME | wc -l) -gt $MAX_LOGIN ]]
then
echo "User $LOGNAME: Login Limit $MAX_LOGIN is over. Try after some time"
sleep 1
exit 1
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-30-2005 12:03 AM
тАО06-30-2005 12:03 AM
Re: limit user login
hth.