Pre-Requirement for SUDO and requireTTY flag

Problem

I'm trying to execute targets but the commands are failing
Within the log file the following error will be seen: sudo: sorry, you must have a tty to run sudo

Reproduction/Solution

The requiretty flag, if set in sudo config file sudoers, sudo will only run when the user is logged in to a real tty. When this flag is set, sudo can only be run from a login session and not via other means such as cron, shell/perl/python or cgi-bin scripts or more command execution. This flag is set on many distribution by default.

  • Edit /etc/sudoers file

  • Find line that read as follows:

Defaults requiretty
  • Either comment it out the line or delete the line:

#Defaults requiretty
  • Save and close the file.

This will allow remote SSH comands that use the sudo command without a pseudoTTY being present.