LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-11-2016, 02:34 PM   #1
mjrwesting
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Rep: Reputation: Disabled
Restrict su to root only


Hello!

All of my internet searches have been futile, so I am now asking you guys. What I want to be able to do is this:
1) Restrict who can su to root, that would be "su" "su -" "su - root".
2) Still allow users to be able to su to other accounts. Such as bob being able to su to dbadmin.

I have played around with implementing this with the wheel group, but I run into the issue that I end up limiting the use of su ONLY to those in the wheel group, and that is not the implementation I want. Again, I want all users to be able to use the su command, but only those with special privileges (wheel group perhaps), to be able to su to root.

I have investigated using sudo, but for this project it will not be acceptable to use sudo before every command.

Lastly, I had tried some editing of the /etc/login.defs to allow (SU_WHEEL_ONLY yes), but that does not seem to work on my OS.

I am trying to accomplish this with a SLES OS (Using a few SLES versions around SLES10 and SLES11).

If you need any other info let me know! I realize this may be an odd request, and there are probably better more secure ways to go about this that don't quite meet my criteria, but for this purpose I am only looking to solve the problem at hand.

Thanks!
 
Old 01-11-2016, 03:04 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,757

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by mjrwesting View Post
Hello!

All of my internet searches have been futile, so I am now asking you guys. What I want to be able to do is this:
1) Restrict who can su to root, that would be "su" "su -" "su - root".
2) Still allow users to be able to su to other accounts. Such as bob being able to su to dbadmin.

I have played around with implementing this with the wheel group, but I run into the issue that I end up limiting the use of su ONLY to those in the wheel group, and that is not the implementation I want. Again, I want all users to be able to use the su command, but only those with special privileges (wheel group perhaps), to be able to su to root.

I have investigated using sudo, but for this project it will not be acceptable to use sudo before every command.

Lastly, I had tried some editing of the /etc/login.defs to allow (SU_WHEEL_ONLY yes), but that does not seem to work on my OS. I am trying to accomplish this with a SLES OS (Using a few SLES versions around SLES10 and SLES11).

If you need any other info let me know! I realize this may be an odd request, and there are probably better more secure ways to go about this that don't quite meet my criteria, but for this purpose I am only looking to solve the problem at hand.
Sudo is what's normally used, and I'd certainly go that route. Your explanation of "not be acceptable to use sudo before every command" is confusing, since the only time you'd be using this is when you type in "su - ..." to start with, implying an interactive session. So "sudo su - ..." wouldn't be too bad, and leave you with a shell as a different user, which is your goal.

That said, you could always use a low-tech solution. Either move the su executable to another name, and write a simple script to check the UID of whomever is running it. If they're root, call the renamed-su as normal. Not root, and the input string is "su - root" or "su -"? Tell them no, and exit. Could also easily make the script check the GID as well.
 
Old 01-11-2016, 03:14 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by mjrwesting View Post
is:
1) Restrict who can su to root, that would be "su" "su -" "su - root".
2) Still allow users to be able to su to other accounts. Such as bob being able to su to dbadmin.
Don't over-think the problem...

Implement a good password policy, then...

1. Don't give the root password to those you do not want to be able to su (root).
2. Give bob the dbadmin password, and any other applicable user passwords

And use sudo for more selective restriction by command or by user.

... or am I missing something?

Last edited by astrogeek; 01-11-2016 at 03:18 PM.
 
1 members found this post helpful.
Old 01-11-2016, 03:26 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
"sudo -i" will give you a root login shell just like "su -".
 
Old 01-12-2016, 07:07 AM   #5
mjrwesting
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Sudo is what's normally used, and I'd certainly go that route. Your explanation of "not be acceptable to use sudo before every command" is confusing, since the only time you'd be using this is when you type in "su - ..." to start with, implying an interactive session. So "sudo su - ..." wouldn't be too bad, and leave you with a shell as a different user, which is your goal.

That said, you could always use a low-tech solution. Either move the su executable to another name, and write a simple script to check the UID of whomever is running it. If they're root, call the renamed-su as normal. Not root, and the input string is "su - root" or "su -"? Tell them no, and exit. Could also easily make the script check the GID as well.
You are right, I should have been clear that for this project it was not acceptable to use an implementation of using sudo before every command; however using it only to su would be acceptable. But with that being said, I'm still not sure how to implement this solution based on my criteria.

Your low-tech solution could possibly work, and if I'm not able to find a better solution I may resort to that.

Thanks!
 
Old 01-12-2016, 07:08 AM   #6
mjrwesting
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by astrogeek View Post
Don't over-think the problem...

Implement a good password policy, then...

1. Don't give the root password to those you do not want to be able to su (root).
2. Give bob the dbadmin password, and any other applicable user passwords

And use sudo for more selective restriction by command or by user.

... or am I missing something?
A good password policy is in place and the root password is given to no one. Even if this is not a practical question, think of it more as a training exercise! Can it be done?
 
Old 01-12-2016, 07:09 AM   #7
mjrwesting
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
"sudo -i" will give you a root login shell just like "su -".
Thank you, I will keep that in mind, but I'm not sure how that helps me here?
 
Old 01-18-2016, 07:04 AM   #8
mjrwesting
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
I appreciate the suggestions and comments thus far; however unfortunately it does not look like this is possible based on my criteria. We can use "sudo su", but I'm still stuck with the same issue being that I want general users to be able to still use su (or sudo su), just not to the root account. The only actual restriction I want in place, is when any user other than those in the "wheel" group attempt to su, or sudo su, to the root account.

So, the following should be allowed:
user1: su - user2
user2: sudo su user1
user3(part of wheel group): su -

not allowed:
user1: su -
user2: sudo su root

I just wanted to throw this out one last time before I seek alternate options!

Thanks
 
Old 01-18-2016, 10:43 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
You just need to set up /etc/sudoers so that members of the "wheel" group can run anything as any user and others can run anything but not as user "root" or group "wheel".

This is only slightly tested:
Code:
%wheel ALL=(ALL) ALL
ALL ALL=(ALL,!root:ALL,!wheel) ALL

Last edited by rknichols; 01-18-2016 at 10:45 AM. Reason: Blasted percent sign bug in this forum
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
restrict root account mr_aliagha Linux - Security 13 07-20-2011 10:19 AM
Restrict root to use su <username> say_hi_ravi Linux - Newbie 3 03-11-2010 04:55 AM
want ot restrict shutdown to root only tataiermail Linux - Security 5 07-12-2007 12:26 AM
restrict access to root / yogaboy Linux - Newbie 4 12-31-2006 08:17 AM
restrict internet access to the root only anubhuti_k Linux - Security 1 02-15-2005 12:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration