我希望默认用户ubuntu能够运行特定服务而不会提示您输入密码。
具体来说systemctl restart unicorn_my_app.service。
已按照此处的说明将用户添加ubuntu到新创建的网上论坛,LimitedAdmins已通过以下方式确认:
$ getent group LimitedAdmins
LimitedAdmins:x:1001:ubuntu
limitedadmins(使用sudo vim)在/etc/sudoers.d包含以下文本的目录中创建了一个新文件:
%LimitedAdmins ALL=NOPASSWD: /etc/init.d/unicorn_ofn_america restart, /etc/init.d/unicorn_ofn_america start
我也尝试过:
%LimitedAdmins ALL=NOPASSWD: /bin/systemctl/unicorn_ofn_america restart, /bin/systemctl/unicorn_ofn_america start
(和/bin/systemd)
的内容/etc/sudoers/是默认值,已通过sudo visudo(或sudo cat /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
(哈希登录#includedir不是注释,而是#include指令语法的一部分)。
但是,运行后仍然出现密码提示 systemctl restart unicorn_my_app.service
服务在init.d目录中:
$ ls -l /etc/init.d | grep unicorn
-rwxr--r-- 1 ubuntu ubuntu 1874 Oct 29 06:47 unicorn_my_app
755在应用程序上尝试过chmodding ,但不要认为应该有所作为,因为ubuntu无论如何都拥有它。
甚至尝试重新启动系统也没有差异。我是否错过了一个步骤,例如重新启动/重新加载)?配置错误?
我还应该提到我曾经vim在其中创建新文件/etc/sudoers.d,因为该visudo命令似乎仅用于编辑/etc/sudoers。