I need two suggestions for making my script working from local server as well as ssh execution
1. How to update the sudoers
In server i have a path
all files of parent and child_dir are owned by tomcat user and group.
-rw-rw-r-- 1 tomcat tomcat 0 Feb 17 02:23 20221119.status -rw-rw-r-- 1 tomcat tomcat 0 Feb 17 02:23 20221116.status -rw-rw-r-- 1 tomcat tomcat 0 Feb 17 02:23 20221112.status
I want user named new_user to able to rename the files under the /var/log/data/status/ as part of my script. I have tried to edit my sudoers file like below but it to run without password because tomcat is application user does not have password, Unsure how to make sudoers changes for it.
new_user ALL=NOPASSWD: /bin/bash /path/my_script [a-z_]* 20[0-9]*
what i want to achieve is, to run without any password
sudo -u new_user /bin/bash /path/my_script
2. Run the script over ssh
My another requirement is to run the same script from other server over ssh, if possible, please help with the syntax
- On server A (Login as my user iamsage) -
i need to run something like this
ssh new_user@remote_host "sudo -u new_user /path/my_script arg1 arg2"