zabbix agent如何使用sudo执行bash脚本?

问题描述 投票:0回答:0

操作系统 Ubuntu 22.04.2 LTS。 我像往常一样做了一切。使用 visudo 我允许 zabbix 用户执行命令:

zabbix ALL=(ALL) NOPASSWD:/root/market-report/docker-compose_restart zabbix-agent2

在zabbix agent本身的配置中,我注册了执行系统命令的权限:

# nano /etc/zabbix/zabbix_agent2.conf
AllowKey=system.run[*]

不工作。报错:

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

好的,我会补充:

# visudo
Defaults:zabbix !requiretty

不工作。 然后我就尝试从这个用户在主机上执行脚本:

# sudo -u zabbix sudo /root/market-report/docker-compose_restart

没办法...

[sudo] password for zabbix:

他还需要什么? 我如何在没有密码的情况下通过 sudo 执行脚本

sudo zabbix sudoers
© www.soinside.com 2019 - 2024. All rights reserved.