How to fix 'sudo: no tty present and no askpass program specified' error? How to fix 'sudo: no tty present and no askpass program specified' error? linux linux

How to fix 'sudo: no tty present and no askpass program specified' error?


Granting the user to use that command without prompting for password should resolve the problem. First open a shell console and type:

sudo visudo

Then edit that file to add to the very end:

username ALL = NOPASSWD: /fullpath/to/command, /fullpath/to/othercommand

eg

john ALL = NOPASSWD: /sbin/poweroff, /sbin/start, /sbin/stop

will allow user john to sudo poweroff, start and stop without being prompted for password.

Look at the bottom of the screen for the keystrokes you need to use in visudo - this is not vi by the way - and exit without saving at the first sign of any problem. Health warning: corrupting this file will have serious consequences, edit with care!


Try:

  1. Use NOPASSWD line for all commands, I mean:

    jenkins ALL=(ALL) NOPASSWD: ALL
  2. Put the line after all other lines in the sudoers file.

That worked for me (Ubuntu 14.04).


Try:

ssh -t remotehost "sudo <cmd>"

This will remove the above errors.