在没有密码的情况下启动systemd服务

时间:2018-09-07 11:28:07

标签: linux service systemd

我正在尝试使用systemctl来启动redis,而无需以root用户身份登录。我创建了一个名为exampleService.service的组,并将帐户添加到testGrouptestAccount和我在/etc/systemd/system中创建了文件testConfig,其内容如下:

/etc/sudoers.d

sudoers文件中也存在行 %testAccount ALL= NOPASSWD: /etc/systemd/system start exampleService.service %testAccount ALL= NOPASSWD: /etc/systemd/system stop exampleService.service %testAccount ALL= NOPASSWD: /etc/systemd/system restart exampleService.service 。现在,当我尝试以#includedir /etc/sudoers.d(以systemctl start exampleService.service身份登录)启动服务时,弹出窗口输入密码,但这不是必需的。我的配置哪里出问题了?

1 个答案:

答案 0 :(得分:-1)

在/ etc / sudoers文件中的以下行添加
testAccount ALL = NOPASSWD:全部

相关问题