sudoers的NOPASSWD:命令:没有TTY present并没有指定任何askpass程序 [英] sudoers NOPASSWD: sudo: no tty present and no askpass program specified
问题描述
我添加了一个用户是这样的:
I have added a user like this:
$ adduser --system --home /no/home --no-create-home --group --disabled-password --disabled-login testuser
将用户添加到一个组:
Added a user to a group:
$ adduser testuser testgroup
添加行sudoers文件(visudo命令):
added lines to sudoers (visudo):
testuser ALL=(ALL) NOPASSWD: ALL
%testgroup ALL=(ALL:ALL) NOPASSWD: ALL
当我尝试运行包含以下内容的bash脚本:
When I try to run the bash script with the following content:
#!/bin/sh
sudo -u testuser /usr/bin/php /usr/local/bin/script.php
但是,当我运行此脚本,我得到的日志中的错误:
But when I run this script, I get the error in the log:
sudo: no tty present and no askpass program specified
编辑: requiretty
不在sudoers文件
requiretty
is not in the sudoers file.
推荐答案
须藤
权限对用户/组要更改的从的不要更改用户的到的
sudo
permissions are about the user/group you are changing from not the user you are changing to.
那么,这些许可行让 TESTUSER
用户和 testgroup
组运行任何命令(如人)没有密码。
So are those permission lines are letting the testuser
user and the testgroup
group run any command (as anyone) without a password.
您需要赋予权限的到的运行脚本来运行命令为的的 TESTUSER
为用户的用户是什么你想要的。
You need to give permission to the user running the script to run commands as the testuser
user for what you want.
假设这是你的意思,让即是。
Assuming that's what you meant to allow that is.
这篇关于sudoers的NOPASSWD:命令:没有TTY present并没有指定任何askpass程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!