Home > Uncategorized > Linux/Nagios: sudo: sorry, you must have a tty to run sudo

Linux/Nagios: sudo: sorry, you must have a tty to run sudo

Problem description:

If you are using Nagios or other monitoring products to check your servers, you might come into the situation running commands which require special permissions (e.g. like running them as the root-user). You have configured sudo permissions and your check runs fine on the terminal, but if the monitoring process/service tries to execute it, you are receiving the following message:

sudo: sorry, you must have a tty to run sudo

Cause:

By default sudo only allows to be executed with a tty:

[root@linux01 ~]# cat /etc/sudoers | grep requiretty
Defaults    requiretty
[root@linux01 ~]#

Problem resolution:

You can either disable requiretty or just disable it for the user you require to use sudo without tty (PREFERRED):

[root@linux01 ~]# cat /etc/sudoers | grep requiretty
Defaults    requiretty
Defaults:myosuser !requiretty
[root@linux01 ~]#
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Connect with Facebook