【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 --
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/500314/viewspace-1562966/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 以root使用者執行命令
- sudo以其他使用者身份身份執行命令-linux命令學習Linux
- Linux sudo 被曝提權漏洞,任意使用者均能以 root 身份執行命令Linux
- 在PHP中以root身份執行外部命令(轉)PHP
- 在redhat 5.4或suse 11以sudo執行需要root使用者許可權的命令Redhat
- 【Linux】Liunx配置sudo 使oracle使用者有root許可權執行指令碼LinuxOracle指令碼
- 設定非root賬號不用sudo直接執行docker命令Docker
- 用大寫字母輸入 Linux 命令以將其作為 sudo 使用者執行Linux
- Linux Sudo 被爆重要漏洞,允許黑客提權執行root命令Linux黑客
- 【轉】批處理命令請求以管理員身份執行
- Runas命令:能讓域使用者/普通User使用者以管理員身份執行指定程式
- 使用root 切換普通使用者提示:[sudo] password for oracle:Oracle
- 分享Linux下的sudo及其配置檔案/etc/sudoers詳細配置Linux
- Win10系統下以管理員身份執行cmd命令的方法Win10
- ansible基於密碼sudo執行命令密碼
- C# 以管理員身份執行WinForm程式C#ORM
- CentOS 使用 sudo 提示使用者不在sudoers檔案中的解決方法CentOS
- 自動部署tomcat,並以普通使用者身份執行 for centos6TomcatCentOS
- win10系統怎麼以管理員身份執行檔案 win10以管理員身份執行的步驟Win10
- Linux伺服器上配置 sudo 及 sudo命令使用Linux伺服器
- win10怎麼以管理員身份執行cmdWin10
- C# 讓程式自動以管理員身份執行C#
- 以SYSTEM使用者執行CMD
- oracle is not in the sudoers fileOracle
- 家庭版win10怎麼取消以管理員身份執行_win10家庭版取消以管理員身份執行的方法Win10
- root使用者執行root.sh失敗怎麼處理
- 判斷當前程式是否"以管理員身份執行"的
- cmd怎麼以管理員身份執行 cmd切換管理員身份方法介紹
- LINUX下使用指令碼直接執行SQLPLUS命令(root使用者下)Linux指令碼SQL
- ubuntu sudoers配置錯誤Ubuntu
- sudo命令
- 使用 sudo 命令出現錯誤
- python實現批次執行命令列Python命令列
- 在 Linux 中執行特定命令而無需 sudo 密碼Linux密碼
- 如何在 Linux 中不輸入密碼執行 sudo 命令Linux密碼
- 筆記本以管理員的身份執行在哪_筆記本怎麼以管理員身份執行電腦筆記
- Oracle RAC重新執行root.sh指令碼Oracle指令碼
- Linux下執行一些命令前加sudo時出現command not found的原因Linux