Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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?
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!
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.