I am running an icinga supervision and have to start a command (perl script) wich need super user rights.
I added the user (nagios) and command (check_dhcp_relayed.pl) to the sudo file and switched of tty requirement (see below). I restarted the icinga service.
-------------------
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/nagios/plugin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
Cmnd_Alias DHCPRELAY = /usr/lib/nagios/plugins/check_dhcp_relayed.pl
Defaults logfile="/var/log/sudo.log"
nagios ALL=NOPASSWD
HCPRELAY
Defaults !requiretty
Defaults!DHCPRELAY !requiretty
Defaults:nagios !requiretty
Defaults:root !requiretty
-------------------------------------------
Still the command cannot be executed. Error message is:
"sudo: no tty present and no askpass program specified"
sudo.log holds the message:
"command not allowed TTY=unknown"
logging in as nagios and starting the script works, so it seems the tty is missing which should be handled with the !requiretty.
Linux distribution is debian 9.9.
Any solution?