Chcę, aby domyślny użytkownik ubuntumógł uruchomić określoną usługę bez pytania o hasło.
Konkretnie systemctl restart unicorn_my_app.service.
Postępowałem zgodnie z instrukcjami tutaj, aby dodać użytkownika ubuntudo nowo utworzonej grupy LimitedAdmins, co potwierdza:
$ getent group LimitedAdmins
LimitedAdmins:x:1001:ubuntu
Utworzono nowy plik limitedadmins(za pomocą sudo vim) w /etc/sudoers.dkatalogu zawierającym następujący tekst:
%LimitedAdmins ALL=NOPASSWD: /etc/init.d/unicorn_ofn_america restart, /etc/init.d/unicorn_ofn_america start
Próbowałem także:
%LimitedAdmins ALL=NOPASSWD: /bin/systemctl/unicorn_ofn_america restart, /bin/systemctl/unicorn_ofn_america start
(I /bin/systemd)
Treść /etc/sudoers/jest wartością domyślną potwierdzoną za pomocą sudo visudo(lub 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
(Logowanie hashowe #includedirnie jest komentarzem, ale częścią składni dyrektywy #include ).
Jednak po uruchomieniu nadal pojawia się monit o podanie hasła systemctl restart unicorn_my_app.service
Usługa znajduje się w init.dkatalogu:
$ ls -l /etc/init.d | grep unicorn
-rwxr--r-- 1 ubuntu ubuntu 1874 Oct 29 06:47 unicorn_my_app
Próbowałem chmodding 755w aplikacji, ale nie sądzę, że powinno to mieć znaczenie, ponieważ ubuntui tak jest jej właścicielem.
Próbowałem nawet zrestartować system bez różnicy. Czy brakuje mi kroku, takiego jak ponowne uruchomienie / przeładowanie)? Konfigurujesz coś źle?
Powinienem również wspomnieć, że kiedyś vimtworzyłem nowy plik /etc/sudoers.d, ponieważ wydaje się, że visudopolecenie służy tylko do edycji /etc/sudoers.