我正在尝试使用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
身份登录)我弹出输入密码,但不应该是必需的。可能存在问题在我的配置?
在/ etc / sudoers文件中添加以下行 testAccount ALL = NOPASSWD:ALL