Script to delete sudo access in redhat 5.4

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to delete sudo access in redhat 5.4
# 1  
Old 03-09-2014
Script to delete sudo access in redhat 5.4

Hi ,
This site is veryhelpful in resolving many issues.I have a request to delete sudo access for 3 users say user1,user2,user3 from around 50 servers in redhat 5.4.I know it is very time consuming to login to each server and delete entry in /etc/sudoers file.Is there any way can i do it using a script.
Appreicate your response on it.Advance thanks for your replies.
# 2  
Old 03-10-2014
To get you started.



for((i=0; i< ${#server_list[@]}; i++))
    ssh root@${server_list[$i]} "sed  -i.bak \"/$regex/d\" /etc/sudoers"

Note : -i is included which will edit the file inline, which also creates a backup file. Once you confirm this works locally, then you can go ahead with full fledged.

# 3  
Old 03-11-2014
Hi ahamed101 thansk for your reply.I have tried below script.after execution it deleted few other id's along with the mention 3 user id's.I have restored sudoers file again from the backup.

i think it is not taking user names from the list it seems.I have tried below script but it has given following result.

for((i=0; i< ${#server_list[@]}; i++))
    ssh root@${server_list[$i]} "sed  -i.bak \"/$regex/d\" /etc/sudoers"

It deleted few other id's
[root@server1 etc]# cat /etc/sudoers|grep kgough
[root@server1 etc]# cat /etc/sudoers|grep llewis
[root@server1 etc]# cat /etc/sudoers|grep bpadhi

appreciate your help on this.Thanks

Last edited by Franklin52; 03-11-2014 at 04:32 AM.. Reason: Please use CODE tags, not ICODE tags for code blocks. Thanks.
# 4  
Old 03-11-2014
Try with


# 5  
Old 03-12-2014
Hi Tried with below option but no luck.It didn't work.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script help on sudo access validation

hello I need help on this. The input is this. server system account name DBA account name x a p y b q z c r so i would like to check the sudo of the user is done or not. this is what i do to check it 1. login as root on server x 2.... (2 Replies)
Discussion started by: Kiran008
2 Replies

2. Shell Programming and Scripting

Using plink with sudo access

I have similar issue as mentioned in 167174-how-run-script-using-batch-file.html It works good, but the control is not coming back to source i tried adding exit to remote script. Thanks, Suresh (0 Replies)
Discussion started by: snsuresh
0 Replies

3. UNIX for Dummies Questions & Answers

Inheriting SUDO access?

I had a question on users inheriting SUDO capabilities of another account. Let's say that there are three users A, B, and C. A has access to Sudo into B. B has access to Sudo into C. Does this give A access to sudo into B and then sudo into C. A -> B B -> C A -> B -> C ? Another example. My... (2 Replies)
Discussion started by: sbcopty
2 Replies

4. Red Hat

Sudo access issue

Hi, I have given access to user mwadmin in shudders file as : mwadmin ALL:NOPASSWD:/www/* /usr/* /opt/* However, not able to execute below command: sudo mkdir -p /usr/test password for mwadmin: Sorry, user mwadmin is not allowed to execute '/bin/mkdir -p /usr/test' as root. ... (4 Replies)
Discussion started by: saurau
4 Replies

5. UNIX for Advanced & Expert Users

Help needed in sudo access

I want to give root access to a user called denielr on server - tsprd01, but do not want to share root password. I have sudoers configured already. He should have all access equal to root. I made this entry in /etc/sudoers, but it is not working denielr tsprd01 =(root) NOPASSWD: ALL I tried to... (2 Replies)
Discussion started by: solaris_1977
2 Replies

6. Ubuntu

Restrict SUDO Access

Linux ubuntu 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux Hi Folks, Please help me. I am bit struck here. Here is the OS info. Linux ubuntu 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux I have a... (17 Replies)
Discussion started by: explorer007
17 Replies

7. UNIX for Dummies Questions & Answers

sudo/root access

I'm actually working with a Ubuntu-System here and have a question about executing a command with 'sudo'. I tried and got a error message like "not allowed". After this I logged in with 'sudo -s' and typed the command without 'sudo'. This worked well. Can please somebody explain me this... (0 Replies)
Discussion started by: daWonderer
0 Replies

8. Shell Programming and Scripting

ONLY SU Sudo access

Hello All, I want to create a script that will do ONLY su to any user on the server with hpadmin login using sudo. Can anyone let me know how can it do it. Regards Ankit (1 Reply)
Discussion started by: ajaincv
1 Replies

9. Linux

sudo access verification

Hi All, I got lots of request with sudo, a manager request, verbal command, do this and do that. The problem with this kind of request is when I added that script and that. It will not be perfect, it's because I can't verify the userid sudo access, I can't reset their password as well, I... (2 Replies)
Discussion started by: itik
2 Replies

10. Solaris

secure access using sudo

I just need to know what should be done on a login user so that no one can access it except through sudo i.e. telnet server login: user NO ACCESS telnet server login: mylogin sudo - user <any command> ACCESS GRANTED thanks (0 Replies)
Discussion started by: melanie_pfefer
0 Replies
Login or Register to Ask a Question