unix

How do I resolve the error “sorry, you must have a tty to run sudo” on my Linux server?

Sometimes when you’re trying to execute scripts remotely you may run into the error “sorry, you must have a tty to run sudo” in /var/log/secure.

This is caused because the default setting of sudoers is to require the user to have a TTY. To resolve this, you can disable that setting by doing the following:

vi /etc/sudoers
Comment out the following line:

Defaults requiretty

Another option is to use ssh -t if your command is executed via ssh remotely.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top