【sudo】配置sudoers实现oracle用户以root身份执行命令

sudo命令可以实现在oracle用户下以root用户身份执行命令,这里给出sudo命令的配置和使用方法。

1.美妙的 sudo 命令存在价值
root用户具有所有的操作权限,是真正的“God”级别的用户,这样是非常危险的,sudo便是权利下放的途径。
使用sudo,我们可以实现将root用户一些特定的权限定制后下放。

2.配置sudoers实现oracle用户以root身份执行命令
我们可以通过配置/etc/sudoers文件完成对sudo的配置。
其实,若想对sudo命令的进行完美配置相对比较复杂,其中包括别名定义和授权规则两大类别,详细的说明可以使用sudo的帮助页进行查看。不过我们若只是为了达到在oracle用户下方便的以root用户身份执行命令,相对是简单的。这里给出配置方法。
1)在root用户下编辑sudoers配置文件
如果不参考sudo命令的帮助页,单纯的从sudoers配置文件中的注释信息中也可以获得有效的调整提示。
[root@secdb1 ~]# vi /etc/sudoers
(1)修改前内容
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
#%wheel ALL=(ALL)       ALL

# Same thing without a password
#%wheel ALL=(ALL)       NOPASSWD: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now

(2)变动内容是将与wheel组相关的配置信息前的注释符号“#”去掉。使所有属于wheel组的用户具有root用户的所有命令执行的权限。

(3)修改后内容
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL)       ALL

# Same thing without a password
%wheel ALL=(ALL)       NOPASSWD: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now

2)将oracle用户添加到wheel组中
[root@secdb1 ~]# vi /etc/group
在group文件中找到“wheel”关键字所在行记录。
在wheel记录后面添加“,oracle”,实现将oracle用户加入到wheel组中

修改前内容
wheel:x:10:root

修改后内容
wheel:x:10:root,oracle

到此,配置阶段结束。此时oracle用户可以通过sudo的方式执行root用户下的所有命令。

3.测试oracle用户下sudo的执行效果
我们可以使用“id”命令简单测试一下sudo命令的可用性。
1)oracle用户下使用id命令获得当前用户的信息
[oracle@secdb1 ~]$ id
uid=500(oracle) gid=501(oinstall) groups=10(wheel),500(dba),501(oinstall) context=user_u:system_r:unconfined_t

2)使用sudo方式执行“id”命令
[oracle@secdb1 ~]$ sudo id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t

很显然,此时的反馈信息中记录了root用户的相关信息,并且此处没有提示输入密码。

4.小结
关于sudo的深入配置方法,请参考sudo的帮助页(可以使用“man sudo”自行查询)。本文给出的是在oracle用户使用sudo命令快速简便的配置方法。简便带来的结果是定制的不够细致,此时oracle用户可以以root身份执行所有命令,没有体现出sudo对权限限制的真谛。

Good luck.

secooler
11.05.14

-- The End --

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-695433/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/519536/viewspace-695433/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值