使用 ACME 使用者重新載入 Apache

使用 ACME 使用者重新載入 Apache

我在 Debian 10 (Buster) 和 Apache 2.4.38 上執行 Web 伺服器。我創建了一個特殊使用者acme來運行用於更新 TLS 憑證的腳本。

$ cat /etc/passwd | grep ^acme
acme:x:1002:1002::/var/acme:/usr/bin/nologin
$ cat /etc/group | grep ^acme
acme:x:1002:

應允許該acme使用者在更新憑證後重新載入 Apache 2 配置。所以我將這一行添加到我的/etc/sudoers使用中visudo(8)

%acme   ALL=(root) NOPASSWD: /etc/init.d/apache2 reload

不幸的是,這不起作用:

$ sudo -u acme /etc/init.d/apache2 reload
[....] Reloading apache2 configuration (via systemctl): apache2.serviceFailed to reload apache2.service: Access denied                                                                                                                  
See system logs and 'systemctl status apache2.service' for details.                                                                                                                                                                     
 failed!

我錯過了什麼嗎?

答案1

你需要使用者 acme 當您執行 sudo 時,而不是使用-u acme.

acme@host:~ $ sudo /etc/init.d/apache2 reload

另一個可能的問題:

%sudoers 文件中的 表示這是acme一個群組。當您的使用者位於名為 的群組中時,這不是問題acme,但如果他不屬於該群組,則會出現問題。

相關內容