Ssh – Run bash script as sudo from windows without interaction

bashsshsudo

I need to execute a bash script as sudo on a remote linux machine from TeamCity running on a windows box. I can execute the script fine from the cmd line using plink, but I am prompted for a password. I need to be able to do this without being prompted for password in order to execute from teamcity.

What are my options?

Best Answer

You need to edit the sudo configuration on the host you want to run the script. Run visudo as root and add a line like this:

USERNAME ALL=(ALL) NOPASSWD: ALL

Replace USERNAME with the user you want to run the script with. This should enable the user to use sudo without entering the password. You might want to limit the use of sudo to the commands you actually need. Look in the sudoers by using visudo for examples how to achieve that.