Syntax for sudoers file is as below
Now Let's understand the components.
USER_ALIAS : User aliases are used to specify users, groups or netgroups.
examples:
HOST_ALIAS: list of hostname, ip addresses, networks and netgroups
examples:
EFECTIVE_USER : Who can run what as who
examples:
COMMAND_ALIAS: Lists of commands ( full path of commands) and directories
examples
Now let's try some usecase
1) user rob to run /bin/su command with root privileges. Same time it restricts using any options/argument and login to root.
2) This lets the admins run all the admin commands on the servers
3) This lets "rob" shutdown his own machine without a password
4) rob should run command hwclock only ( without any arguments)
USER_ALIAS HOST_ALIAS=EFECTIVE_USER) COMMAND_ALIAS
Now Let's understand the components.
USER_ALIAS : User aliases are used to specify users, groups or netgroups.
examples:
User_Alias ADMINS = %adminUser_Alias WEBMASTERS = tom,robUser_Alias LIMITED_USERS = !WEBMASTERS, !ADMINS
HOST_ALIAS: list of hostname, ip addresses, networks and netgroups
examples:
Host_Alias SERVERS = 192.168.0.1, 192.168.0.2, server1Host_Alias WORKSTATIONS = 192.168.0.0/255.255.255.0, !SERVERS
EFECTIVE_USER : Who can run what as who
examples:
User_Alias EFECTIVE_USER = sam,rob
COMMAND_ALIAS: Lists of commands ( full path of commands) and directories
examples
Cmnd_Alias SBIN_CMDS = /sbinCmnd_Alias APP_CMDS = /usr/bin/passwd, /sbin/service httpd *, /sbin/ifconfig : DB_CMDS = /bin/su – admin, /home/admin/zabbix_server : ADMIN_CMDS = /sbin/, /usr/sbin/
Now let's try some usecase
1) user rob to run /bin/su command with root privileges. Same time it restricts using any options/argument and login to root.
rob ALL = (root) /bin/su [!-]*[!root]*
2) This lets the admins run all the admin commands on the servers
ADMINS SERVERS= ADMIN_CMDS
3) This lets "rob" shutdown his own machine without a password
rob rob-machine= NOPASSWD: SHUTDOWN_CMDS
4) rob should run command hwclock only ( without any arguments)
rob ALL = (ALL) /sbin/hwclock “”
No comments:
Post a Comment