Service functions without sudo
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system
:
[Service]
User=buildman
When I am su
ed as buildman, I can run:
systemctl status myservice.service
but if I try to do start
or stop
, it prompts me for password.
If I do:
sudo systemctl status myservice.service
it does not prompt me because I have configured visudo
:
%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service
But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.
The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.
sudo services
 |Â
show 1 more comment
up vote
1
down vote
favorite
My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system
:
[Service]
User=buildman
When I am su
ed as buildman, I can run:
systemctl status myservice.service
but if I try to do start
or stop
, it prompts me for password.
If I do:
sudo systemctl status myservice.service
it does not prompt me because I have configured visudo
:
%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service
But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.
The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.
sudo services
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
your suggestion still requiressudo
â amphibient
Oct 20 '17 at 17:46
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36
 |Â
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system
:
[Service]
User=buildman
When I am su
ed as buildman, I can run:
systemctl status myservice.service
but if I try to do start
or stop
, it prompts me for password.
If I do:
sudo systemctl status myservice.service
it does not prompt me because I have configured visudo
:
%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service
But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.
The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.
sudo services
My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system
:
[Service]
User=buildman
When I am su
ed as buildman, I can run:
systemctl status myservice.service
but if I try to do start
or stop
, it prompts me for password.
If I do:
sudo systemctl status myservice.service
it does not prompt me because I have configured visudo
:
%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service
But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.
The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.
sudo services
edited Oct 20 '17 at 17:03
dhag
10.7k32742
10.7k32742
asked Oct 20 '17 at 16:57
amphibient
4,42993469
4,42993469
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
your suggestion still requiressudo
â amphibient
Oct 20 '17 at 17:46
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36
 |Â
show 1 more comment
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
your suggestion still requiressudo
â amphibient
Oct 20 '17 at 17:46
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
your suggestion still requires
sudo
â amphibient
Oct 20 '17 at 17:46
your suggestion still requires
sudo
â amphibient
Oct 20 '17 at 17:46
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
status
command does not require superuser rights, it works w/o sudo
too.start
and stop
do require sudo
. You can avoid entering password but not specifying sudo.
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
status
command does not require superuser rights, it works w/o sudo
too.start
and stop
do require sudo
. You can avoid entering password but not specifying sudo.
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
add a comment |Â
up vote
0
down vote
status
command does not require superuser rights, it works w/o sudo
too.start
and stop
do require sudo
. You can avoid entering password but not specifying sudo.
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
add a comment |Â
up vote
0
down vote
up vote
0
down vote
status
command does not require superuser rights, it works w/o sudo
too.start
and stop
do require sudo
. You can avoid entering password but not specifying sudo.
status
command does not require superuser rights, it works w/o sudo
too.start
and stop
do require sudo
. You can avoid entering password but not specifying sudo.
edited Oct 20 '17 at 18:48
answered Oct 20 '17 at 18:08
Tagwint
1,3181612
1,3181612
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
add a comment |Â
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
I tried 1 and it didn't work. How do I do your #2 suggestion?
â amphibient
Oct 20 '17 at 18:12
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
â Tagwint
Oct 20 '17 at 18:31
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
this OP asks for a way to do away with sudo
â amphibient
Oct 20 '17 at 18:36
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
â Tagwint
Oct 20 '17 at 18:45
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399388%2fservice-functions-without-sudo%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
â Tagwint
Oct 20 '17 at 17:37
your suggestion still requires
sudo
â amphibient
Oct 20 '17 at 17:46
that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
â Tagwint
Oct 20 '17 at 17:52
Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
â Tagwint
Oct 20 '17 at 18:33
yes, that group does exist
â amphibient
Oct 20 '17 at 18:36