Here i will put helpful info regarding "sudoers" file.
User interaction
Check if you may run a specific command sudo -l /usr/bin/top
Run command as root sudo command
Run a command as another user sudo -u user command
With privilege, see which commands another user may run sudo -U user -l
Sudoers File FormatThe sudoers file is composed of two types of entries: aliases (basically variables) and user specifications (which specify who may run what). When multiple entries match for a user, they are applied in order. Where there are multiple matches, the last match is used (which is not necessarily the most specific match). Aliases Alias ::= 'User_Alias' User_Alias (':' User_Alias)* |
User aliasesUsers and groups of users must be referenced by user and groups of users only. Each "level" of numerically) levels of access for that group. UNIX groups defined by LDAP must be used rather than listing individual users. Listing individual users is allowed for special system users only. A subgroup of users that needs to perform certaint role may be defined on rare ocasion. Following rules apply to each Alias name:
Alias definition:
| ||||||||||||
Host aliases Following rules apply to each Host_Alias definition. Alias name: Must begin with a CAPITAL letter. May contain CAPITAL letters, numbers, and underscores(_) in their name only. Alias definitions: May be a machine name returned from the command hostname. May be IP addresses or CIDR (will match any IP on any real interface on the machine except loopback): 10.24.0.5 or 10.24.0.0/30 May be a Host_Alias: SAO May be a glob: dns*, ns?, host9[0-7] May be a combination of any of the above, multiples are comma-space separated: SAO, server1, www9[0-7], samson, 10.24.0.0/30, 10.24.0.5 May use negation with !: SAO, server1, www9[0-7], !samson, !10.24.0.0/30, !10.24.0.5 | ||||||||||||
Runas aliasesFollowing rules apply to each Alias name:
Alias definition:
Command aliasesEach command should have its own This allows for not having to re-create similar Inherit/build-upon Following rules apply to each Alias name:
Alias definitions:
Real world exampleUsers " and "running", as the user " This request translates to sudo rule:
If users requesting access are all in the system group "
If the group "dnsadmins" doesn't exist, we can also define an alias within sudo:
Perhaps our DNS servers aren't as nicely named as dns*, a host alias may be used:
We can also alias commands:
Which takes us to the final ruleset: # Aliases User_Alias DNSADMINS = user1, user2 Host_Alias DNSSERVERS = dns*, strangehostnamedns Cmnd_Alias NSDC_STOPSTART = /usr/sbin/acdc (start)? (stop)? (running)? # Commands # USERS HOSTS = (RUNAS) COMMANDS DNSADMINS DNSSERVERS = (root) NSDC_STOPSTART
|
Comments
Post a Comment