LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-21-2006, 11:54 AM   #1
jwholey
LQ Newbie
 
Registered: Mar 2006
Posts: 19

Rep: Reputation: 0
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.
 
Old 03-21-2006, 12:00 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
Take a look here, maybe you'll find something that will help.
 
Old 03-21-2006, 12:14 PM   #3
jwholey
LQ Newbie
 
Registered: Mar 2006
Posts: 19

Original Poster
Rep: Reputation: 0
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.
 
Old 03-21-2006, 10:09 PM   #4
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
Moderator note: This thread will probably get more exposure in the Linux-Security forum. Moving thread there.
 
Old 03-21-2006, 10:22 PM   #5
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,286

Rep: Reputation: 62
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

Last edited by fotoguy; 03-21-2006 at 10:32 PM.
 
Old 03-22-2006, 04:46 AM   #6
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
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.
 
Old 03-22-2006, 05:29 AM   #7
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,286

Rep: Reputation: 62
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.
 
Old 03-22-2006, 05:36 AM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
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.
 
Old 03-22-2006, 06:24 PM   #9
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,286

Rep: Reputation: 62
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.
 
Old 03-26-2006, 08:18 AM   #10
~=gr3p=~
Member
 
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227

Rep: Reputation: 30
hope tis helps:
http://www.puschitz.com/SecuringLinu...SharedAccounts
 
Old 03-27-2006, 06:58 AM   #11
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,286

Rep: Reputation: 62
Quote:
Originally Posted by ~=gr3p=~

Thanks for the link , that has some fantastic tips.
 
Old 04-01-2006, 08:35 AM   #12
Vincent_Vega
Member
 
Registered: Nov 2003
Location: South Jersey
Distribution: Slackware, Raspbian, Manjaro
Posts: 826

Rep: Reputation: 31
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.
 
Old 04-01-2006, 08:04 PM   #13
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,286

Rep: Reputation: 62
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.
 
Old 04-01-2006, 11:27 PM   #14
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Rep: Reputation: 32
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.

Last edited by Wynd; 04-01-2006 at 11:29 PM.
 
Old 04-01-2006, 11:41 PM   #15
HGeneAnthony
Member
 
Registered: Mar 2003
Posts: 178

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 08:28 AM
How to prevent root relaying in sendmail MensaWater *BSD 11 02-07-2006 01:10 PM
Prevent Root access with SSH rshooper Linux - Security 4 11-18-2004 01:05 PM
root files: create as root:root or root:wheel? pcass Linux - Security 1 02-07-2004 04:14 PM
prevent an IP to get out? jimval7 Linux - Security 16 05-09-2003 09:58 AM

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

All times are GMT -5. The time now is 07:39 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration