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?