sudo -i不需要密码?

最近在用云服务器的时候发现一个问题,不管当我用密码还是key的方式ssh到云服务器的时候。

sudo -i不需要密码都可以切换到root!刚登陆就敲的,之前没有sudo过。

怎么会有这么bug的命令啊!

是那个地方的设置问题么?

而且我的问题不好搜索,带上-这种字符都过滤掉了。

/etc/sudoers如下:

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

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

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
阅读 10.4k
4 个回答

假设你的系统是centos,从你的描述来看,说明你执行sudo -i的用户已经配置过无密码sudo到root用户的权限。
可以新建一个普通用户来测试下,假设你的系统中现在没有test这个用户,用root用户执行以下命令行测试:

useradd test
su - test
sudo -i

su或者sudo命令下输入过密码, 获取到root权限后, 15分钟内, 使用sudo -i或者sudo su都是免密码进入root模式的.
可以去/etc/sudoers, 修改配置.

clipboard.png

新手上路,请多包涵
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL,!/bin/bash

在ALL后添加 !/bin/bash,如上

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题