LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2014, 11:33 AM   #1
melybee
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Rep: Reputation: Disabled
How can I search for a user account in various sudo related config files?


-1
down vote
favorite
I'm a scripting newbie...and I would like to search multiple servers for user ss7459 in the following files /etc/sudoers, /etc/sudoers.d/itse, /etc/sudoers.d/dbas and /etc/group.

NOTE: The numbers after the ss may not be constant across all the servers... on some it may be ss3945... and so on but it all starts with ss.

Can someone please help me write a script for this?

Also, I'll be running this on a satellite with all servers on it thus the main aim is to find out all the servers with that user (ss7***) on them. I'll also be needing a way to get the servers name and compile a list of those servers.
 
Old 06-17-2014, 02:00 PM   #2
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 494
Blog Entries: 3

Rep: Reputation: 157Reputation: 157
I'd do it something like this:
Code:
#!/usr/bin/env bash

_files=('/etc/sudoers' '/etc/sudoers.d/itse' '/etc/sudoers.d/dbas' '/etc/group')

for f in ${_files[@]}; do
        grep 'ss[0-9][0-9][0-9][0-9]' $f

done
That would give you a list of all entries that exist in those files.

You could redirect output to a file. EG; save that script as blah.sh;
Code:
# chmod +x && blah.sh > servers.txt
 
1 members found this post helpful.
Old 06-17-2014, 02:05 PM   #3
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
You will have to do a little bit of searching my friend!
This is easily done and you would find lots of info just searching the net.

I'll give you a few hints though:
To search in file content: use 'grep'
To run a script remotely: configure ssh keys and execute 'ssh "my_script" (just one way to do it!)
 
1 members found this post helpful.
Old 06-17-2014, 02:09 PM   #4
melybee
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
thanks pingu...i had figured out the first part, with the grep but i have several servers(over 200)...
configuring ssh keys may be a little bulky...is there some way around it that you know...

and thanks too Coralfang!
 
Old 06-17-2014, 02:16 PM   #5
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
If you have over 200 servers then surely you have administrative tools!???!

... hmm or could it be that you're a student and this is actually homework? ;-)
 
Old 06-17-2014, 02:43 PM   #6
melybee
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
no...not student...
i do have the rhn satellite...i'm just trying to figure out a way to have the output with the server info along with the output before posting the script on the satellite...
 
Old 06-17-2014, 02:52 PM   #7
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Ok I see - hadn't heard of "rhn satellite" before.
Since this is a platform for managing multiple servers it surely has what you're looking for.
I suggest you write a new question, specifically saying you need help with rhn satellite. I would be very surprised if a management tool like this doesn't have ways to extract everything you need.
 
Old 06-17-2014, 02:54 PM   #8
melybee
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
sorry...rh satellite..(redhat satellite)

again thanks for your time...i'll dig in a little bit more...
 
Old 06-18-2014, 06:36 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
If you're adminning 200+ servers, you're likely to be doing a lot of this sort of stuff, in which case the initial investment up front of setting up ssh keys will pay dividends down the line.
 
  


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
[SOLVED] user account related linux_world Linux - Security 5 02-14-2013 12:14 PM
SELinux user context staff_u and sudo issues. Also, question related to setting conte ohlookpie Linux - Security 6 06-19-2012 03:00 PM
After improper shutdown, 1 user can't startx (KDE), sudo, OR su. Root account is ok! ShellyCat Linux - Desktop 2 09-19-2010 04:56 AM
Can sbdy give config files for gmail account for sending with mutt for a normal user? frenchn00b Linux - Newbie 1 07-24-2007 02:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:43 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