How to solve the sudoers error – “sorry, you must have a tty to run sudo”

Updated on September 3, 2017

I configured my sudoers file to run a command without a password and without a login terminal, but when execute the command, got the below error:

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

Sudo Error : No tty
Sudo Error : No tty

Sol: My sudoers configuration was to execute the file without password and without any tty. So, there is a probability that my /etc/sudoers file (or any other file it includes) has:

Defaults requiretty

This configuration makes the sudo behavior to always require a controlling terminal. That is, SUDO is expected to be run from a login terminal. As this doesn’t provide any real security benefit, it can be safely removed or commented.

After removing or commenting, restart sshd service

service sshd restart

Red Hat has closed the bug by dropping the requiretty Defaults setting from sudoers.

As a turn-around, if you are not able to fix the issue on server side, execute the command with




options to ssh which creates a pseudo-terminal on the remote side.

Was this article helpful?

Related Articles

Leave a Comment