启动没有密码的systemd服务[关闭]

问题描述 投票:-3回答:1

我正在尝试使用systemctl启动我的exampleService.service,而不是以root身份登录。我创建了一个名为testGroup的组并在那里添加了我的帐户 - testAccount.My服务文件位于/etc/systemd/system,我在testConfig中创建了文件/etc/sudoers.d,其中包含以下内容:

 %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存在于sudoers文件中。现在当我尝试启动服务时:systemctl start exampleService.service(以testAccount身份登录)我弹出输入密码,但不应该是必需的。可能存在问题在我的配置?

linux service systemd
1个回答
-1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.