我需要完成以下几件事。
禁用 Ubuntu 用户。
sudo su
对所有用户禁用。
每个用户都应该能够执行sudo <command>
.
我修改了我的 sudoer 文件如下:
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Cmnd_Alias NSHELLS = /bin/sh,/bin/bash
Cmnd_Alias NSU = /bin/su
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
**%sysadmins ALL=(ALL) NOPASSWD:ALL ,!NSHELLS, !NSU**
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
Run Code Online (Sandbox Code Playgroud)
不过,我可以使用以下命令访问 sudo:sudo sudo su
如何禁用此功能?任何帮助都受到高度赞赏。
恕我直言,如果你得到了你想要的东西并且有人可以跑sudo <anything but su>
,他们可以:
sudo bash
sudo -i
su
)。sudo visudo
我想说明的一点是,如果你允许人们运行任何东西(甚至几乎任何东西),他们就和 root 一样好。他们可以绕过你的方式数不胜数。
如果您只希望他们能够以 root 身份运行有限数量的命令,请创建一个新组(例如semisudo
)并将每个命令添加到sudoers
,如下所示:
%semisudo localhost=/path/to/command
%semisudo localhost=/path/to/another/command
Run Code Online (Sandbox Code Playgroud)
然后将用户添加到该组并将他们踢出admin
/ sudo
。
归档时间: |
|
查看次数: |
13379 次 |
最近记录: |