Monday, October 25, 2021

[SOLVED] How to enable sudo from Jenkins SSH plugin?

Issue

I tried running a sudo command from the Jenkins SSH plugin but got the following error:

sudo: sorry, you must have a tty to run sudo

My Jenkins job needs to be able to stop and start a service and I was unable to enable the remote user to do it without sudo.

Is there any way to enable sudo-ing from Jenkins?


Solution

I managed to enable sudo from Jenkins by changing sudoers on the remote host (SSH target) to not require tty:

#Defaults    requiretty


Answered By - amphibient