使用 CentOS 7 AWS 实例。我在所有情况下都遇到以下问题
===================================================
[oms.deployer.acc@********* ~]$ service httpd restart
Redirecting to /bin/systemctl restart httpd.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Multiple identities can be used for authentication:
Cloud User (ec2-user)
oms.deployer.acc
Choose identity to authenticate as (1-2):
===========================================================
我正在尝试oms.deployer.acc
使用静态用户并且也有轮子访问权限。
我需要以普通用户重新启动 httpd 服务。
答案1
我相信不建议发明自行车的最简单方法是sudo
。您仍然可以为用户提供有限数量的命令,即systemctl restart httpd
通过使用visudo
# visudo
添加这样的行:
nonprivuser ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd
保存文件并测试它:
# su - nonprivuser
$ sudo /bin/systemctl restart httpd