user29463327
user29463327

Reputation:

Restricting a sudo command to specific arguments

I'm trying to restrict a sudo command to specific arguments. In particular, arguments to systemctl.

I want a user to be able to stop, start and restart specific services on the server. So if we use httpd and mysql as the example. I'd imagine this would work.

Sudo version is 1.9.15p5 running on Ubuntu 24.04

user  ALL=(root) NOPASSWD: /usr/bin/systemctl (stop|start|restart) (httpd|mysql)

I still got prompted for a password every time. Is there any way to achieve this without writing all possible combinations (which equates to 30 lines on the system in question)?

Upvotes: 2

Views: 39

Answers (0)

Related Questions