- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Direct Login VS. su only
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
тАО09-12-2007 01:10 AM
тАО09-12-2007 01:10 AM
Here's the script from another thread:
Since all normal shell logins go through /etc/profile, there are a number of controls you can put into /etc/profile. As mentioned, you can limit root so it is not allowed a direct login except through the console, and indirectly using su (or better yet, sudo). For the rest of the users, you might create a file of disallowed users such as /etc/disallowed.users with each user login on a separate line such as:
billh
jamesf
kens
Then near the top of /etc/profile (ALWAYS after the line: trap "" 1 2 3) add something like this:
for NOTALLOWED in $(cat /etc/disallowed)
do
if [ $LOGNAME = $NOTALLOWED ]
then
echo "\n --- login not allowed ---\"
exit
fi
And that's it. Now anytime billh, jamesf or kens try to login, they are kicked out immediately.
Thanks
Solved! Go to Solution.
- Tags:
- su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 01:22 AM
тАО09-12-2007 01:22 AM
SolutionIf you are truly doing 'su - user' and not 'su user' then '/etc/profile' should be sourced.
If you test '$0' (the running process) in 'etc/profile' you will see either '-sh' for a normal login or '-su' if the user issued 'su - user'. That's one way to distinguish a direct login from an 'su'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 03:31 AM
тАО09-12-2007 03:31 AM
Re: Direct Login VS. su only
Here's an exaple of the code I suggested in my post, above:
if [ ${0} = "-sh" ]; then
if [ ${LOGNAME} = "bob" ]; then
echo "...login is direct; you MUST 'su -' to login"
sleep 5
exit
fi
fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 05:32 AM
тАО09-12-2007 05:32 AM
Re: Direct Login VS. su only
After the trap "" 1 2 3 command in the /etc/profile, I added the following commands. Your suggestions worked fine, I just combined them.
for NOTALLOWED in $(cat /etc/disallowed.users)
do
if [ $LOGNAME = $NOTALLOWED ] && [ ${0} = "-sh" ]
then
echo "\n Direct logins not allowed for your account."
echo "\n You must su - $NOTALLOWED from another user."
read
exit
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 05:33 AM
тАО09-12-2007 05:33 AM
Re: Direct Login VS. su only
After the trap "" 1 2 3 command in the /etc/profile, I added the following commands. Your suggestions worked fine, I just combined them.
for NOTALLOWED in $(cat /etc/disallowed.users)
do
if [ $LOGNAME = $NOTALLOWED ] && [ ${0} = "-sh" ]
then
echo "\n Direct logins not allowed for your account."
echo "\n You must su - $NOTALLOWED from another user."
read
exit
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 05:34 AM
тАО09-12-2007 05:34 AM