sudo不再要求密码

分享于 

3分钟阅读

ubuntu

  繁體

问题

这是/etc/sudoers文件:


#


# 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"



# 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



# 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


%jupiter ALL=NOPASSWD: /usr/lib/jupiter/scripts/bluetooth, /usr/lib/jupiter/scripts/camera, /usr/lib/jupiter/scripts/cpu-control, /usr/lib/jupiter/scripts/resolutions, /usr/lib/jupiter/scripts/rotate, /usr/lib/jupiter/scripts/touchpad, /usr/lib/jupiter/scripts/vga-out, /usr/lib/jupiter/scripts/wifi



如何使sudo始终提示我输入密码?


答案1

最后一行是罪魁祸首,

你应该考虑以下行:


# Please consider adding local content in /etc/sudoers.d/ instead of


# directly modifying this file.



删除最后一行并将它放入/etc/sudoers.d/sudo-jupiter,现在将/etc/sudoers的权限恢复为ux,并重新启动系统。


答案2


jobin ALL=(root) NOPASSWD:ALL


Defaults:jobin secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin



为了解决这个问题,删除/etc/sudoers.d/50_stack_sh文件(我不再需要openstack了),对于需要openstack和密码提示的用户,请将文件/etc/sudoers.d/50_stack_sh的内容更改为:


<username> ALL=(root) ALL


Defaults:<username> secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin



用需要密码提示的帐户的用户名替换<username>


password  ANY  SUDO  
相关文章