sudo: a terminal is required to read the password; either use..... 问题解决方法

发布时间 2023-08-09 10:30:41作者: ShineLe
转载自:sudo: a terminal is required to read the password; either use ……问题解决方法_akaiziyou的博客-CSDN博客

问题

sudo: a terminal is required to read the password; either use the -S option to read from standard in or configure an askpass helper

出现场景

某个用户在shell脚本中使用了sudo指令,此时需要为sudo命令输入密码

解决方法

1)编辑文件/etc/sudoers(以下指令拼写是正确的,请不要误认为vi应该分开)

sudo visudo
#或
sudo vim /etc/sudoers

2)找到“root  ALL=(ALL)  ALL”一行,在下面插入“用户  ALL=(ALL:ALL) NOPASSWD:ALL”语句,保存(需要用wq!强制退出)退出