我阅读了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.
任何想法都会受到热烈欢迎:-)
丹尼斯
解决方法
@H_403_25@ 除非您想以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策略.