I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo
.
When I compile the sources from a terminal all goes fine and the make is paused the first time a sudo
command is ran waiting for password. Once I type in the password, make resumes and completes.
But I would like to be able to compile the sources in NetBeans. So, I started a project and showed netbeans where to find the sources, but when I compile the project it gives the error:
sudo: no tty present and no askpass program specified
The first time it hits a sudo
command.
I have looked up the issue on the internet and all the solutions I found point to one thing: disabling the password for this user. Since the user in question here is root. I do not want to do that.
Is there any other solution?
After all alternatives, I found:
Source
Above command still needs password to be entered. To remove entering password manually, in cases like jenkins, this command works:
I think I can help someone with my case.
First, I changed the user setting in
/etc/sudoers
referring to above answer. But It still didn't work.In my case,
myuser
was in themygroup
.And I didn't need groups. So, deleted that line.
(Shouldn't delete that line like me, just marking the comment.)
It works!
Try:
Use
NOPASSWD
line for all commands, I mean:Put the line after all other lines in the
sudoers
file.That worked for me (Ubuntu 14.04).
Login into your linux. Fire following commands. Be careful, as editing sudoer is a risky proposition.
Once vi editor opens make the following changes:
Comment out
Defaults requiretty
Go to the end of the file and add
This worked for me:
where your user is "myuser"
for a Docker image, that would just be:
Command
sudo
fails as it is trying to prompt on root password and there is no pseudo-tty allocated (as it's part of the script).You need to either log-in as root to run this command or set-up the following rules in your
/etc/sudoers
(or:sudo visudo
):Then make sure that your user belongs to
admin
group (orwheel
).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