Wednesday, March 3, 2010

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

SkyHi @ Wednesday, March 03, 2010

Per customer request, we recently wrote a script to restart their application server around 3AM via crontab every night. We were alerted that their server did not come back up this morning. After investigating, we found the following output in the log file:

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

If you ever encounter this error, you need to use the ‘visudo’ command and locate the following line:

Defaults    requiretty<br />

Just comment out the line, and you will resolve the issue.

If this option is set, 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 or cgi-bin scripts.


REFERENCE

http://www.adminmyserver.com/articles/sorry-you-must-have-a-tty-to-run-sudo