LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   How to prevent su to root? (https://www.linuxquestions.org/questions/linux-security-4/how-to-prevent-su-to-root-426968/)

jwholey 03-21-2006 11:54 AM

How to prevent su to root?
 
I've installed sudo and sudoscripting on my RHEL AS3 implementation. I would now like to prevent everyone from su"ing" to the root user. I'd prefer that all use the "ss -u root" command as it will provide a much better audit trail. Can anyone point me in the direction of how I can prevent su to root. Thanks.

reddazz 03-21-2006 12:00 PM

Take a look here, maybe you'll find something that will help.

jwholey 03-21-2006 12:14 PM

Reddazz, I already read that (that's RHL 9 workstation security). The info is good, but I'm just tring to lock down "su -". Have yet to come across a simple way to do it. thx.

Capt_Caveman 03-21-2006 10:09 PM

Moderator note: This thread will probably get more exposure in the Linux-Security forum. Moving thread there.

fotoguy 03-21-2006 10:22 PM

Try

chgrp wheel /bin/su
chmod 4750 /bin/su
chmod +s /bin/su

Now the only people who will be allowed to 'su' to root must be part of the wheel group. Just make sure the people you want to be part of the wheel group are part of that group first, otherwise you may not be able yourself to 'su' to root after this to add them to it.

Plus you can add this to the /root/.bashrc file and this will email you if someone manages to 'su' to root or login as root:

ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@youraddress.com

Apparentely this can be bypassed through ssh if they use:

ssh user@example.com /bin/bash --noprofile --norc

But if add the line to /root/.ssh/rc file (might need to create it first)it is apparentely read before they have actually logged in, I haven't had a chance to verify this just yet

reddazz 03-22-2006 04:46 AM

Thats exactly what the article I linked to was suggesting but jwholey said it wasn't helpful. This is the way its done in FreeBSD. You cannot use su unless you are part of the wheel group.

fotoguy 03-22-2006 05:29 AM

Quote:

Originally Posted by reddazz
Thats exactly what the article I linked to was suggesting but jwholey said it wasn't helpful. This is the way its done in FreeBSD. You cannot use su unless you are part of the wheel group.


I didn't read your link till now, but I have seen that page in the past. The only way then to lock it down quickly and simply would be to change the permissions and groups.

That is why FreeBSD and all the other unix are very secure and stable.

reddazz 03-22-2006 05:36 AM

Quote:

Originally Posted by fotoguy
I didn't read your link till now, but I have seen that page in the past. The only way then to lock it down quickly and simply would be to change the permissions and groups.

That is why FreeBSD and all the other unix are very secure and stable.

True. I think the problem with some Linux distros is that a lot of things are being dumbed down by distro maintainers because they want non technical people to be able to use Linux as well. So out of the box the BSDs are usually more secure than Linux, but Linux can be configured to be highly secure by a good sysadmin. :)

fotoguy 03-22-2006 06:24 PM

That's why I writing my own hardening script for linux, it will have all the tips and tricks I can find to help make it as secure as possible.

~=gr3p=~ 03-26-2006 08:18 AM

hope tis helps:
http://www.puschitz.com/SecuringLinu...SharedAccounts

fotoguy 03-27-2006 06:58 AM

Quote:

Originally Posted by ~=gr3p=~


Thanks for the link , that has some fantastic tips.
:study:

Vincent_Vega 04-01-2006 08:35 AM

Is there any reason you can't just chmod -x /bin/su? If you want to prevent everyone from using that command, would that work or is there some other problems this would cause that I'm not aware of? I would like to know, just out of curiosity.

fotoguy 04-01-2006 08:04 PM

Quote:

Originally Posted by Vincent_Vega
Is there any reason you can't just chmod -x /bin/su? If you want to prevent everyone from using that command, would that work or is there some other problems this would cause that I'm not aware of? I would like to know, just out of curiosity.


That will only stop them from executing it, but through the permissions some users will still be able to have access to the file.

Plus it's not a good idea to restrict all users and not allow atleast one user from being able to 'su' to root.

If you have secured the machine properly and disallow root to login from console, remote, SSH and GUI(KDM and GDM) then you will never be able to administer the system or add software to it, basically locked root out for good.

Wynd 04-01-2006 11:27 PM

What about using /etc/suauth?

To shut everyone out, use:
ALL:ALL:DENY

Or to make it like BSD and only allow members of the wheel group:
ALL:ALL EXCEPT GROUP wheel:DENY

Then you may want to (as root) chmod 600 /etc/suauth for safety. Hope this helps.

Edit: 'man suauth' for more info.

HGeneAnthony 04-01-2006 11:41 PM

Reply
 
Add yourself to the root/wheel group and go into /etc/pam.d/su and uncomment out:

auth required pam_wheel.so

Before you log out of the root open another terminal and login as a regular user and try to su. If you can it worked. If not since you're still root in another shell go in and fix it. Also I would recommend going into /etc/securetty and deleting all the contents. This will block root from logging in directly on your machine. Then go into /etc/sshd_config and change permitrootlogin to no. This will stop someone from logging in remotely as root. I also recommend changing the protocol to 2 only. Now the only way to be root is by su from an account in the wheel/root group. PAM won't be affected go apps that prompt for a root password like kuser and such will still prompt you for the root password. Get bastille as well to lock down your system.


All times are GMT -5. The time now is 09:46 AM.