- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Letting only one instance of a user logging in...
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
12-03-2003 06:58 PM
12-03-2003 06:58 PM
In HPUX, can you restrict a user to login only once? For example, the user "foo" can only login once in a certain machine. I.e., whenever you issue the who command, foo can only appear once, not more.
Thanks,
Vince
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:12 PM
12-03-2003 07:12 PM
Solutionif [ $(who | grep "^`whoami` ") -gt 1 ]
then
echo "Sorry, but you're already logged in"
exit
fi
Mind the space between the back-quote and the double quote... It ensures that small differences between usernames are not mistreated. For instance test3 shouldn't be kicked if only test is logged in. The same for the leading carrot.
To do it using a login shell is trickier, since it should be a binary file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:14 PM
12-03-2003 07:14 PM
Re: Letting only one instance of a user logging in to a machine
In the .profile just count login shells for the user "-ksh" using "ps" or directly read utmp or use "last" and just exit if there are more than you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:27 PM
12-03-2003 07:27 PM
Re: Letting only one instance of a user logging in to a machine
I cannot get your script to work. In scripting I am rubbish. Didn't understand regarding spaces and stuff.
Can you please rephrase? :-)
Thanks,
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:47 PM
12-03-2003 07:47 PM
Re: Letting only one instance of a user logging in to a machine
It should be: grep
Are there any errors or things like that you get from my 'script' (which is only a part of a script and needs to be added to a .profile or /etc/profile to work) that could help solve the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:49 PM
12-03-2003 07:49 PM
Re: Letting only one instance of a user logging in to a machine
I got to work by adding wc -l like this:
if [ $(who | grep foo | wc -l) -gt 1 ]
then
echo "bla bla"
fi
Thanks, case closed.
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:54 PM
12-03-2003 07:54 PM
Re: Letting only one instance of a user logging in to a machine
Glad it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 07:56 PM
12-03-2003 07:56 PM
Re: Letting only one instance of a user logging in to a machine
Also, note that this won't stop people logging in as someone else and doing an su but you can't have everything :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 08:00 PM
12-03-2003 08:00 PM
Re: Letting only one instance of a user logging in to a machine
Case closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 09:01 PM
12-03-2003 09:01 PM
Re: Letting only one instance of a user logging in to a machine
I know you've marked this question as closed, but I thought you might be interested to know that HP-UX does have that functionality without having to add extra scripts.
The NUMBER_OF_LOGINS_ALLOWED parameter in /etc/default/security defines the number of logins for non-root users. It's available at 11.00 (providing you have PHCO_27004 - login patch [which also requires PHCO_25976]), and at 11i. The security(4) man page is available on 11i systems, or at http://docs.hp.com
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:13 AM
12-04-2003 12:13 AM
Re: Letting only one instance of a user logging in to a machine
must the system be a trusted system that this will work or does this work with a normal system, too??
THX
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:20 AM
12-04-2003 12:20 AM
Re: Letting only one instance of a user logging in to a machine
No, it doesn't have to be trusted. Do a man on security. The man page may not be up to date with all the latest features, but it will get you started.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:21 AM
12-04-2003 12:21 AM
Re: Letting only one instance of a user logging in to a machine
It will work irrespective of that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:25 AM
12-04-2003 12:25 AM
Re: Letting only one instance of a user logging in to a machine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 03:56 AM
12-04-2003 03:56 AM
Re: Letting only one instance of a user logging in to a machine
you can modify this to kill hte new login... by grepping for the process for the telnet session.
MY_TTY=`tty | cut -f3- -d'/'`
USERS=`finger -fim ${LOGNAME} | grep -v "${MY_TTY}"`
case "${USERS}" in
${LOGNAME}*"Not Logged In"|"") ;;
*) TIME=`date '+%T'`
for TTY in `cut -c12-19 << EOF
${USERS}
EOF
`
do
test -w /dev/${TTY} && echo "SECURITY WARNING!!^G^G Another user
is
logging on to ${LOGNAME} at ${TIME}" > /dev/${TTY}
done
echo "*********************************************************"
echo "* SECURITY WARNING!!^G^G ${LOGNAME} already logged on! IDLE *"
sed -e 's/^/* /' -e 's/$/ */' << EOF
${USERS}
EOF
echo "*********************************************************"
esac