Do not set "root" as "NOPASSWD" in sudoers file
cat /etc/sudoers
root ALL=(ALL)ALL: ALL
do not change it to
root ALL=(ALL)NOPASSWD: ALL
Since root should always have a password. Then we could login by command "su"
-------------------------------
讲解sudo配置文件/etc/sudoers的格式。
# User privilege specification
root ALL=(ALL) ALL
# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
以上是我的Ubuntu10.04的默认/etc/sudoers文件。"#"开头的都是注释可以忽略。
首先用户需要转换成根用户并使用visudo命令打开/etc/sudoers文件。
讲解:root ALL=(ALL) ALL
root表示被授权的用户,这里是根用户;
第一个ALL表示所有计算机;
第二个ALL表示所有用户;
第三个ALL表示所有命令;
全句的意思是:授权根用户在所有计算机上以所有用户的身份运行所有文件。
%admin ALL=(ALL) ALL同上面一样,只不过被授权的成了admin这个组。
通用格式
/etc/sudoers的通用格式为:
user host run_as command
user:一位或几位用户,在/etc/group中可以用一个%代替它,组对象的名称一定要用百分号%开头。
host:一个或几个主机名;
run_as:作为哪个用户运行,常见选项是root和ALL
command:想让用户或组运行的一个或几个根级别命令。
例如:
hans ALL=(root) useradd,userdel
授权hans用户在所有计算机上以root身份运行useradd,userdel命令。
%smith ALL=(ALL) NOPASSWD:useradd,userdel
授权smith组全部成员在所有计算机上以所有用户的身份运行useradd,userdel命令;且运行时不必输入密码。
需要注意的是,当我们为用户定义可以运行的命令时,必须使用完整的命令路径。这样做是完全出于安全的考虑,如果我们给出的命令只是简单的userad
而非
/usr/sbin/useradd,那么用户有可能创建一个他自己的脚本,也叫做userad,然后放在它的本地路径中,如此一来他就能够通过这个名为
useradd的本地脚本,作为root来执行任何他想要的命令了。这是相当危险的
Do not set "root" as "NOPASSWD" in sudoers file的更多相关文章
- oracle is not in the sudoers file. This incident will be reported.
准备把OS的root禁用了,所以其他用户要执行使用root执行的操作时,需要使用sudo. 在没有配置sudo的时候,执行sudo会出现类似以下的报错: [oracle@test ~]$ sudo / ...
- centos添加和删除用户及 xxx is not in the sudoers file.This incident will be reported.的解决方法
修改主机名:vim /etc/sysconfig/network 1.添加用户,首先用adduser命令添加一个普通用户,命令如下: #adduser tommy //添加一个名为tommy的用户 # ...
- XXX 用户 is not in the sudoers file. This incident will be reported 的问题解决方案
说的是,这种问题,是出现在ubuntu系统里. root@SparkSingleNode:/usr/local/jdk# pwd /usr/local/jdk root@SparkSingleNode ...
- ubuntu:xxx is not in the sudoers file. 问题解决
ubuntu 下普通用户用 sudo 执行命令时报 "xxx is not in the sudoers file.This incident will be reported" ...
- XXXX is not in the sudoers file. This incident will be reported解决方法
假设你用的是Red Hat系列(包括Fedora和CentOS)的Linux系统.当你执行sudo命令时可能会提示“某某用户 is not in the sudoers file. This inc ...
- XXX is not in the sudoers file. This incident will be reported 的问题解决方案
不多说,直接上干货! 说的是,这种问题,是出现在ubuntu系统里. root@SparkSingleNode:/usr/local/jdk# pwd /usr/local/jdk root@Spar ...
- lxs1314 is not in the sudoers file. This incident will be reported.
虚拟机下面 普通用户用sudo执行命令时报"xxx is not in the sudoers file.This incident will be reported"错误,解决 ...
- 解决:xxx is not in the sudoers file.This incident will be reported.的解决方法
Linux中普通用户用sudo执行命令时报”xxx is not in the sudoers file.This incident will be reported”错误,解决方法就是在/etc/s ...
- Linux中新建用户用不了sudo命令问题:rootr is not in the sudoers file.This incident will be reported解决
参考:https://blog.csdn.net/lichangzai/article/details/39501025 如果执行sudo命令的用户没有执行sudo的权限,执行sudo命令时会报下面的 ...
随机推荐
- Winscp使用密钥登录
Winscp使用密钥登录 背景:通常我们使用winscp通过密码认证去连接服务器进行文件的ftp操作,但是为了安全,我们服务器上经常会禁止使用密码连接,而改用密钥认证.而且服务器上经常会禁止root用 ...
- fsockopen函数被禁用的解决方法
判断fsockopen 是否可用:function_exists('fsockopen');如果没有开启 一.开启fsockopen函数 修改php.ini,将 disable_functions = ...
- Helvetic Coding Contest 2016 online mirror A1
Description Tonight is brain dinner night and all zombies will gather together to scarf down some de ...
- php中静态绑定
自 PHP 5.3.0 起,PHP 增加了一个叫做后期静态绑定的功能,用于在继承范围内引用静态调用的类. 虽然也可以调用非静态方法,但是不会在运行时绑定. static 不再只是简单的静态修饰关键字. ...
- 1.Ioc&DI和Spring
1.面向对象回顾和案例 面向对象程序设计:1 2 3 4 案例分析: 需求分析: 报表功能: 报表服务类,检索数据,并生成图标 报表生成器类,生成不同格式的报表文件,例如PDF格式.H ...
- Spring配置问题:The prefix "util" for element "util:map" is not bound.
在spring的头部文件中没有引入: xmlns:util=”http://www.springframework.org/schema/util” 原文:https://blog.csdn.net/ ...
- Doxygen生成美丽注释文档(1):初体验
Chapter 1 - 准备工作 (Windows环境) 1.1 程序包下载 1. Doxygen * 源码: git clone https://github.com/doxygen/doxygen ...
- js实现放大镜效果
原理: 鼠标在小图片上移动时,通过捕捉鼠标在小图片上的位置,定位大图片的相应位置: 放大镜的移动方向和大图片的移动方向:横向和纵向都是相反,才可以保证同步: 需要元素:大图和小图,存放大图和小图的容器 ...
- perf命令
@(Linux基础)[perf命令] perf命令 ---- 简介 Perf是内置于Linux内核源码树中的性能剖析(profiling)工具,它基于事件采样原理,以性能事件为基础,支持针对处理器相关 ...
- [转]jQuery.getJSON的缓存问题的解决办法
本文转自:http://mfan.iteye.com/blog/974132 今天做测试工作,发现了一个令我费解的问题,jquery的getJson方法在firefox上运行可以得到返回的结果,但是在 ...