加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – sudo在使用NOPASSWD时仍然要求输入密码

发布时间:2020-12-14 02:53:23 所属栏目:Linux 来源:网络整理
导读:我阅读了serverfault上的所有sudo帖子,但我仍然无法弄清楚我做错了什么.通常我终于找到解决方案但不是这次: 我希望apache用户能够以“hremotessh”用户身份执行此命令: sudo /home/hremotessh/scripts/redirect.sh 8892 8893 因此我在visudo中添加了这个:
我阅读了serverfault上的所有sudo帖子,但我仍然无法弄清楚我做错了什么.通常我终于找到解决方案但不是这次:

我希望apache用户能够以“hremotessh”用户身份执行此命令:

sudo /home/hremotessh/scripts/redirect.sh 8892 8893

因此我在visudo中添加了这个:

apache ALL=(hremotessh) NOPASSWD: /home/hremotessh/scripts/redirect.sh

但是sudo还在问密码吗?

sudo /home/hremotessh/scripts/redirect.sh
[sudo] password for apache:

我试过这个,但不是更好:

sudo -u hremotessh /home/hremotessh/scripts/redirect.sh
hremotessh is not in the sudoers file.  This incident will be reported.

任何想法都会受到热烈欢迎:-)

丹尼斯

解决方法

除非您想以root身份运行命令,否则需要指定用户名
su - apache -s /bin/bash 
 sudo -u hremotessh /home/hremotessh/scripts/redirect.sh 8892 8893

是测试sudo命令的正确语法.

由于没有提示您输入apache用户的密码,因此sudo似乎配置正确.

结果警告:hremotessh不在sudoers文件中.表示在redirect.sh脚本中使用了另一个sudo命令.并且该用户没有(有效的)sudo策略.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读