0

I'm configuring remote deployment using rsync over ssh and there is need to execute a sudo command without password.

This is my visudo:

# Allow user to execute specified commands without password Cmnd_Alias USER_SERVICES = /bin/systemctl reload nginx, /usr/sbin/nginx -t [user] ALL=(ALL) NOPASSWD:USER_SERVICES 

With this setting i can confirm that specified commands can be executed manually(me typing these commands) without password prompt but whenever running that commands on script file like below it asks me the password.

#! /bin/bash ... sudo systemctl reload nginx ... 

How can i avoid password prompt in this case?

1 Answer 1

1

The two commands systemctl reload nginx and /bin/systemctl reload nginx are not identical. The first depends on the directories included in the PATH environment variable, while the second one does not.

The sudoers files gives you the ability to use /bin/systemctl reload nginx so that is what you should use.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.