在CentOS-7中设置Sudo

前端之家收集整理的这篇文章主要介绍了在CentOS-7中设置Sudo前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在CentOS 6.5中,我将执行以下操作为用户设置sudo –

> useradd -G wheel -c“John Smith”jsmith
> visudo
>取消注释此行 – %wheel ALL =(ALL)ALL
> usermod -G wheel -a jsmith
> restart sshd – /etc/init.d/sshd restart
> ssh登录为jsmith并输入’sudo bash’

当我在CentOS 7中尝试相同的事情时,我在/ var / log / secure中看到以下内容

Oct  8 05:20:00 localhost sudo: jsmith : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/jsmith ; USER=root ; COMMAND=/bin/bash

这个程序对CentOS-7不再有效吗?

更多信息 –

文件/ etc / group有这个 –

wheel:x:10:randomperson,cartman,jsmith

visudo显示了这个 –

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL

## Allows members of the 'sys' group to run networking,software,## service management apps and more.
# %sys ALL = NETWORKING,SOFTWARE,SERVICES,STORAGE,DELEGATING,PROCESSES,LOCATE,DRIVERS

## Allows people in group wheel to run all commands
wheel   ALL=(ALL)       ALL

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

输出sudo -l命令 –

[jsmith@localhost ~]$sudo -l
[sudo] password for jsmith:
Sorry,user jsmith may not run sudo on localhost.
[jsmith@localhost ~]$
您发布的示例中缺少’%’.

它应该是

%wheel   ALL=(ALL)       ALL

wheel   ALL=(ALL)       ALL
原文链接:https://www.f2er.com/centos/373367.html

猜你在找的CentOS相关文章