打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

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

2017.07.11

关注
命令存在价值
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 --

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
使用用sudo时提示"### is not in the sudoers file. This incident will be reported.
linux 为普通用户配置sudo权限
变换用户身份为root的方法su 与 sudo
关于su和sudo以及visudo的很好的介绍性文档
Linux 系统中的超级权限的控制
转贴:Ubuntu进入root权限命令
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服