sudoers: how to disable requiretty per user

I don't want to comment out the line in /etc/sudoers:

Defaults    requiretty

Instead, I only want a certain user not to require a tty. How can this be done?


Solution 1:

You said that you want one particular user to not require a tty. That's the default behavior. Nevertheless, you can explicitly set that like this:

Defaults:username !requiretty

If you want everyone else to require a tty, then you'll have to uncommment the line.

Solution 2:

RedHat now recommends removing 'Defaults requiretty', conforming with the source code defaults. In Security Advisory RHSA-2016:2593, Redhat patched /etc/sudoers, removing line 'Defaults requiretty'

For additional details, see: https://bugzilla.redhat.com/show_bug.cgi?id=1196451 https://bugzilla.redhat.com/attachment.cgi?id=1155247&action=diff

Also, per user requiretty exceptions DO NOT WORK for RHEL/CENTOS 7 (sudo 1.8.6p7)