如何禁用Ubuntu16.04LTS普通用户关机?

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
visitma
帖子: 5
注册时间: 2017-02-28 17:42
系统: ubuntu16.04lts

如何禁用Ubuntu16.04LTS普通用户关机?

#1

帖子 visitma » 2017-02-28 17:51

Ubuntu16.04TLS加入Windows域以后,使用domian users账号登录进入ubuntu桌面,可以运行关机、重启这些命令,请问如何禁止domain users在nubuntu16.04TLS系统中的关机权限?谢谢!

/etc/sudoers中的内容如下:

Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
root ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
#includedir /etc/sudoers.d

是否与这个有关?如果是,请问该怎样更改?
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#2

帖子 poloshiao » 2017-02-28 18:43

普通用户
該 普通用户 可以使用 sudo 嗎
visitma
帖子: 5
注册时间: 2017-02-28 17:42
系统: ubuntu16.04lts

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#3

帖子 visitma » 2017-03-01 8:24

poloshiao 写了:
普通用户
該 普通用户 可以使用 sudo 嗎
是的,可以使用sudo命令,请问如何限制其不能使用 sudo 命令?
visitma
帖子: 5
注册时间: 2017-02-28 17:42
系统: ubuntu16.04lts

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#4

帖子 visitma » 2017-03-01 8:26

poloshiao 写了:
普通用户
該 普通用户 可以使用 sudo 嗎
是的,该普通用户可以使用sudo 请问如何限制这个用户不能使用sudo呢?
这个用户是AD域中一个组的成员,如何限制这个组的成员在ubuntu上都没有sudo权限?
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#5

帖子 poloshiao » 2017-03-01 10:52

如何限制这个用户不能使用sudo呢?
在 Ubuntu
假設 該用戶名稱為 hisusername
sudo cat /etc/group | grep sudo | grep hisusername
如果 有 hisusername 表示 hisusername 能使用 sudo
如果 沒有 hisusername 表示 hisusername 不能使用 sudo
不能使用 sudo 通常無法關機或重新開機

意思是 如果該用戶 原來可以使用 sudo
從 group sudo 中 將該用戶移除即可
(除非 你還更改了一些其它預設情況)
visitma
帖子: 5
注册时间: 2017-02-28 17:42
系统: ubuntu16.04lts

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#6

帖子 visitma » 2017-03-01 11:10

我要禁止sudo的用户是windowsAD域中的用户。执行
sudo cat /etc/group | grep sudo | grep test\user01
sudo cat /etc/group | grep sudo | grep user01
均无结果显示

我想会不会应该要修改/etc/sudoers文件中这以下内容:

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

但是我不知道改成什么内容才对?
1、只允许指定的用户和root用户可以有sudo权限
2、来自windowsAD域中的用户无sudo权限 无关机、重启权限
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#7

帖子 poloshiao » 2017-03-01 11:18

我要禁止sudo的用户是windowsAD域中的用户。执行
sudo cat /etc/group | grep sudo | grep test\user01
sudo cat /etc/group | grep sudo | grep user01
均无结果显示
1. 你是在哪一台電腦 操作上述指令 ?
我想会不会应该要修改/etc/sudoers文件中这以下内容:
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
2. 除非你對於 Ubuntu 權限設定很熟悉 否則 不建議 直接修改 /etc/sudoers 檔案內容
1、只允许指定的用户和root用户可以有sudo权限
3. 你在這裡 把 root 用户權限 跟 sudo 群組成員的權限 混淆了
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#8

帖子 poloshiao » 2017-03-01 11:25

windowsAD域
1. 建議
不要修改 /etc/sudoers 原來的權限設定
而是 增加一行 專門設定 windowsAD域 主機/群組 的 權限

1-1. 修改 /etc/sudoers
1-1-1. 要修改 /etc/sudoers 請記得先看看這一篇文章
https://help.ubuntu.com/community/Sudoers
sudo visudo
1-1-2. /etc/sudoers 權限設定意思
http://www.tecmint.com/su-vs-sudo-and-h ... -in-linux/
Difference Between su and sudo and How to Configure sudo in Linux
root ALL=(ALL) ALL
adam ALL=(ALL) ALL
tom ALL=(ALL) ALL
mark ALL=(ALL) ALL
1-1-3. ALL=(ALL:ALL) ALL 權限設定意思
http://askubuntu.com/a/546228
What is the difference between `root ALL=(ALL:ALL) ALL` and `root ALL=(ALL) ALL`?
1-1-4. http://askubuntu.com/questions/455211/h ... to-sudoers
How to add Domain Admins to sudoers

1-2. 再把要授予該群組權限的成員 個別加入 該群組
http://askubuntu.com/questions/66718/ho ... and-groups
使用 usermod 關鍵字 搜尋這一篇文章
visitma
帖子: 5
注册时间: 2017-02-28 17:42
系统: ubuntu16.04lts

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#9

帖子 visitma » 2017-03-01 11:30

poloshiao 写了:
我要禁止sudo的用户是windowsAD域中的用户。执行
sudo cat /etc/group | grep sudo | grep test\user01
sudo cat /etc/group | grep sudo | grep user01
均无结果显示
1. 你是在哪一台電腦 操作上述指令 ?
我在需要禁用windowsAD域账号sudo权限的这台ubuntu电脑上操作的

不修改/etc/sudoers文件中的内容时,我该如何禁用windowsAD域用户账号在这ubuntu中的sudo权限?请指导,谢谢!
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 如何禁用Ubuntu16.04LTS普通用户关机?

#10

帖子 poloshiao » 2017-03-01 11:46

不修改/etc/sudoers文件中的内容时,我该如何禁用windowsAD域用户账号在这ubuntu中的sudo权限?请指导,谢谢!
參閱
viewtopic.php?p=3186405#p3186405
回复