I have a local script that will not run without root privs on the remote host. I have edited and allowed the sudoers file to run the script from the home dir (/home/username/script). The script creates a txt file with the results but I redirect the output to terminal and pipe the output to a text file on the local machine.
I cannot "ssh user@hostname sudo -Sv < script.sh > results.txt" because this will not run the script from the remote host, specifically the home dir.
Does anyone know of a way (one line) to copy the script to the remote host & execute it as root while retrieving the output?
Thank you for any assistance