如何修复“sudo: no tty present and no askpass program specified"错误? [英] How to fix 'sudo: no tty present and no askpass program specified' error?

查看:50
本文介绍了如何修复“sudo: no tty present and no askpass program specified"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 makefile 编译一些源代码.在 makefile 中有一堆命令需要作为 sudo 运行.

当我从终端编译源代码时一切正常,并且在第一次运行 sudo 命令等待密码时 make 暂停.输入密码后,制作简历并完成.

但我希望能够在 NetBeans 中编译源代码.所以,我启动了一个项目并向 netbeans 展示了在哪里可以找到源代码,但是当我编译该项目时,它给出了错误:

sudo:不存在 tty 且未指定 askpass 程序

第一次遇到 sudo 命令.

我在互联网上查过这个问题,我找到的所有解决方案都指向一件事:禁用该用户的密码.因为这里有问题的用户是 root.我不想那样做.

还有其他解决办法吗?

解决方案

授予用户使用该命令而不提示输入密码应该可以解决问题.首先打开一个 shell 控制台并输入:

sudo visudo

然后编辑该文件以添加到最后:

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

例如

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

将允许用户 john sudo poweroffstartstop 而不会提示输入密码.>

在屏幕底部查看您需要在 visudo 中使用的按键 - 顺便说一下,这不是 vi - 并在出现任何问题的第一个迹象时退出而不保存.健康警告:破坏此文件后果严重,慎重编辑!

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?

解决方案

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!

这篇关于如何修复“sudo: no tty present and no askpass program specified"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆