InsideDarkWeb.com

Allow user to run PHP-FPM without password using sudoers

I’m trying to make it so a user can reload PHP-FPM without needing a password everytime.

I’ve added the following to the /etc/sudoers file using pkexec visudo, and there are no syntax errors, but it is still not working, any ideas?

Defaults exempt_group=forge
User_Alias FORGE = forge
Cmnd_Alias FORGE_COMMANDS = /usr/sbin/service php-fpm *
FORGE ALL = (ALL) NOPASSWD: FORGE_COMMANDS

I’ve hunted everywhere and this seems to be a common problem of getting it to work, but each question doesn’t seem to have an answer, or one that works for me.

Using CentOS 7.

Thanks.


When using sudo -u I get the following:

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Multiple identities can be used for authentication:

I can then proceed as normal, but the point is for forge to be able to do this without requiring authentication.

Unix & Linux Asked by Seán McCabe on November 21, 2021

1 Answers

One Answer

Managed to get this working after additional hunting.

Turns out the addition to the sudoers file needed to be in the right place, not just at the bottom of the file where everyone apparently tells you to put it.

So after:

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

and before:

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

I put in:

## Allows forge to restart the php-fpm service
forge ALL=NOPASSWD: /usr/sbin/service php-fpm restart

Hopefully this will help a few people out, seems to be a lot of people out there having the same issue.

Just replace forge with the user you want to grant the permission too.

Answered by Seán McCabe on November 21, 2021

Add your own answers!

Related Questions

Authentication fails though the password is correct

0  Asked on September 3, 2020 by rohit-pillai

     

Cant’t load Windows 10 anymore

1  Asked on August 31, 2020 by j-doe

       

Change order a icons in system tray widget in KDE?

1  Asked on August 29, 2020 by paddy

 

rts5139/rtsx_usb borked in 3.15+

2  Asked on August 27, 2020 by roman

     

ETH0 no address ip with ifconfig

1  Asked on August 24, 2020 by akame14

     

Kali Linux 2020.2 Wifi Not Working (Realtek)

0  Asked on August 18, 2020 by harriet

     

Base64 encoded ignition file gets messed up

1  Asked on August 15, 2020 by michael-stbich

     

Weird textures on KDE Plasma 5.0

0  Asked on August 11, 2020 by rushisrinivas-k

     

How do I syntax check a Zsh script?

1  Asked on August 9, 2020 by akhil-jalagam

     

How can I swap my two screens, left to right?

5  Asked on August 4, 2020 by ripper234

         

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.