I have one build machine which has a user abc which is has limited sudo access. When I check out the source code and run my build script, it works fine. The build script contains sudo calls for which it does not say "sudo: no tty present and no askpass program specified". But when I did same thing with Jenkins on a build machine added as slave, it shows "sudo: no tty present and no askpass program specified".

I have found one solution saying to comment out Default requiretty in the file /etc/sudoers. But I don’t have access to this file.

How I can overcome this problem?

  • Is this command you're trying to run via sudo allowed to run without entering a password? If you have to enter a password, sudo is going to require a tty. – Patrick Oct 13 '14 at 13:09
  • Yes ..it runs without entering a password – Niraj Oct 14 '14 at 4:58

There are two options, comment out the Defaults requiretty setting from /etc/sudoers as you mentioned or use the pseudo-tty allocation (-t) argument for ssh.

Try the following in your jenkins script:

ssh -t "sudo command"

Although you will have to have ssh pre-shared keys configured to yourself and run it once manually to add an entry to known hosts, alternatively add the -o StrictHostKeyChecking=no argument to ssh to ignore this.


It fails, because sudo is trying to prompt on root password and there is no pseudo-tty allocated.

You've to either log-in as root or set-up the following rules in your /etc/sudoers (or: sudo visudo):

# Members of the admin group may gain root privileges.

Then make sure that your Jenkins user belongs to admin group (or wheel).

Ideally (safer) it would be to limit root privileges only to specific commands which can be specified as %admin ALL=(ALL) NOPASSWD:/path/to/program


If you are executing commands via ssh, you need to check the "Exec in pty" option. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.