0

Using CentOS 7 AWS instance. I got the below problem in all the instances

===================================================
[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):
===========================================================

I am trying from oms.deployer.acc which is a static user and also have wheel access.

I need to restart the httpd service with normal user.

1 Answer 1

3

I believe the easiest way that will not suggest inventing a bycicle is going to be sudo. You still can provide user with limited number of commands, namely the systemctl restart httpd by using visudo

# visudo

add line like this:

nonprivuser ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd

save file and test it:

# su - nonprivuser
$ sudo /bin/systemctl restart httpd
3
  • What does the ALL=(ALL) mean? For the command after the NOPASSWD:, should those be comma-delimited if you need to provide that user with multiple capabilities, or how do you list multiple commands out?
    – Ungeheuer
    Jul 27, 2019 at 19:31
  • 1
    @Ungeheuer the first ALL is the tty. Meaning, user is allowed to work on any tty. Second ALL is as user, meaning, the user can work on any tty and run on behalf of all users. Everything that goes after this referst to commands. So root, for example, should have ALL=(ALL:ALL) ALL - he can work on ANY tty, as ANY user of ANY group to run ANY command. In my exacmple I replace the last ALL (any command) with the specific command. And you can use comma as a delimeter for multiple commands, eg. NOPASSWD: commands1, commands2
    – deimos
    Jul 29, 2019 at 13:42
  • Thanks deimos! Excellent explanation. +1 from me
    – Ungeheuer
    Jul 29, 2019 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .