用户使用 sudo? NOPASSWD: sudo: 不是终端而不是 askpass 指示程序

我添加了这样的用户:


$ adduser --system --home /no/home --no-create-home --group --disabled-password --disabled-login testuser


向组添加用户:


$ adduser testuser testgroup


添加字符串以使用用户 sudo? /visudo/:


testuser ALL=/ALL/ NOPASSWD: ALL
%testgroup ALL=/ALL:ALL/ NOPASSWD: ALL


当我尝试运行脚本时 bash 具有以下内容:


#!/bin/sh
sudo -u testuser /usr/bin/php /usr/local/bin/script.php


但是当我运行此脚本时,我会得到一个杂志错误:


sudo: no tty present and no askpass program specified


Edit:
requiretty

没有文件 sudoers.
已邀请:

涵秋

赞同来自:

sudo

权限属于用户/群组,你改变,和

不是改变的用户

.

因此,这些行权限允许用户
testuser

和集团
testgroup

执行任何团队 /就像任何其他人一样/ 没有密码。

您需要提供许可

用户运行脚本运行命令

经过

用户名
testuser

对于你想要的东西。

假设这就是你所想到的允许它。

裸奔

赞同来自:

您的文件发生此错误 sudoers 表示
requiretty

. 从参考页面
sudoers

:


requiretty If set, sudo will only run when the user is 
logged in to a real tty. When this flag is set,
sudo can only be run from a login session and not
via other means such as cron/8/ or cgi-bin scripts.
This flag is off by default.


纠正错误,删除
requiretty

从文件。 sudoers.

龙天

赞同来自:

我通过输入服务器并将以下行添加到配置中来纠正它 ssh-server:


> vim /etc/ssh/sshd_config

Match User <your name="" user="">
PermitTTY yes


所以我不需要选择
-t

不断地。
</your>

要回复问题请先登录注册