OS Ubuntu 22.04.2 LTS.
I did everything as usual. Using visudo I allowed the zabbix user to execute the command:
zabbix ALL=(ALL) NOPASSWD:/root/market-report/docker-compose_restart zabbix-agent2
In the config of the zabbix agent itself, I registered permission to execute system commands:
# nano /etc/zabbix/zabbix_agent2.conf
AllowKey=system.run[*]
Does not work. Gives an error:
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
Okay, I’ll add:
# visudo
Defaults:zabbix !requiretty
Does not work.
Then I just try to execute the script on the host from this user:
# sudo -u zabbix sudo /root/market-report/docker-compose_restart
No way…
[sudo] password for zabbix:
What else does he need?
How I may executing script throught sudo without password
2
Answers
Generally made easier. Moved the script to another folder and gave the owner to user zabbix
You can configure your system to run sudo without password:
https://linuxhandbook.com/sudo-without-password/