linux - 无密码启动 systemd 服务
问题描述
我正在尝试exampleService.service
使用 systemctl 启动我,而不以 root 身份登录。我创建了名为的组testGroup
并在那里添加了我的帐户 - 。testAccount
我的服务文件位于/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中添加以下行
推荐阅读
- javascript - 如何在JS中将数字格式更改为小数
- visual-studio - Visual Studio 2019 中的字体加载问题
- python - 将多个类序列化为 JSON
- jquery - 如何使用从 NuGet Package Visual Studio 2019 安装的 jQuery
- javascript - 如何将 vue 组件中的数据组织到一个结构中?
- c# - 如何根据窗口宽度自动调整 GridView 项目的外观和宽度
- sql - 使用 ADO 和 SQL 的 VBA 单元格参考
- r - 从浏览器访问 RStudio
- python - 将 .dat 文件转换为 .jpg 或 .png
- javascript - 如何从 url 中获取一些内容并将其放在 html 中的输入框中