LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sudoers (https://www.linuxquestions.org/questions/linux-newbie-8/sudoers-4175440277/)

Spartan@007 12-06-2012 09:04 AM

Sudoers
 
Hiee,

Can anyone let me know if two sudoers file csn be maintained in RHEL servers. I had tried to search in on WEB but didn't much info on this. Can anyone help me on this. It would be gr8 help for me!!

Thanks

TB0ne 12-06-2012 09:32 AM

Quote:

Originally Posted by Spartan@007 (Post 4843805)
Hiee,
Can anyone let me know if two sudoers file csn be maintained in RHEL servers. I had tried to search in on WEB but didn't much info on this. Can anyone help me on this. It would be gr8 help for me!!
Thanks

Please don't use text-speak here.

The short answer is "no"...there is one sudoers file. You can centralize it for multiple servers in some cases, but there's only one. However, you CAN include other files into the sudoers file. When someone tries to run sudo, it will run through the sudoers file, until it reaches that include file, process it, then continue. Tell us what you're trying to accomplish/do with such a scenario, and maybe we can suggest other options. The sudoers manual is here:

http://www.sudo.ws/sudoers.man.html

acid_kewpie 12-06-2012 09:34 AM

It woudl help if you described what you want to achieve from these two files, but maybe the sudoers.d / sudo.d directory is what you want? long ago sudo added an "include" directive, which will load all files in a single directory.

a bit of human level info here... http://www.peppertop.com/blog/?p=1015

Spartan@007 12-06-2012 10:31 AM

Hi,

Thanks for your reply. I want to add sudoers entry in many servers in one go through scripting. Problem is that script will re-create the sudoers file deleting old entries.So i want to know is there any possibility that i can create a new file in /etc/sudo.d directory.

TobiSGD 12-06-2012 12:51 PM

Quote:

Originally Posted by Spartan@007 (Post 4843862)
Problem is that script will re-create the sudoers file deleting old entries.

Use the >> redirector in your script, instead of the > redirector. This will append to the file, not overwrite it.

Quote:

So i want to know is there any possibility that i can create a new file in /etc/sudo.d directory.
Just create a file there and put in the contents you need.

Warning: Keep in mind that syntax errors in the sudoers files will render sudo unusable. This will be a serious problem if sudo is the only way on that systems to get root privileges. Extensive testing is needed before using that on production systems.

TB0ne 12-06-2012 03:38 PM

Quote:

Originally Posted by Spartan@007 (Post 4843862)
Hi,

Thanks for your reply. I want to add sudoers entry in many servers in one go through scripting. Problem is that script will re-create the sudoers file deleting old entries.So i want to know is there any possibility that i can create a new file in /etc/sudo.d directory.

TobiSGD pointed out the ">>" directive, but scripting modifications to the sudoers file is an invitation to trouble. First, the script itself would have to run with root privileges, making it a security vulnerability. Second, ANY problems with the script renders ALL of the sudo users unable to get in/work, since the sudoers file will be corrupted. Third, unless you modify the file with 'visudo' (the ONLY recommended way), getting the permissions/ownership correct will be problematic, since if *THEY'RE* wrong, the file is also unusable.

You can centralize your sudoers file, so you can have ONE for multiple servers. Some possible solutions are posted here:
http://serverfault.com/questions/906...o-sudoers-file

You don't say if you're using LDAP or not, but you can tie in LDAP with SUDO too. You can also use puppet or SVN to deploy sudoers as well, so you can maintain ONE file, rather than trying to script together something that may cause numerous problems.

acid_kewpie 12-07-2012 02:11 AM

Quote:

Originally Posted by Spartan@007 (Post 4843862)
Hi,

Thanks for your reply. I want to add sudoers entry in many servers in one go through scripting. Problem is that script will re-create the sudoers file deleting old entries.So i want to know is there any possibility that i can create a new file in /etc/sudo.d directory.

well do you have one? Clearly if the system is set up right then it is possible. Look to see, and give it a try.

As above, puppet is excellent, highly recommended for things like this.


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