sudo: sorry, you must have a tty to run sudo
After configuring IPA or Sudoers rules, while you are trying to run the sudo command you'll come across this issue.
[root@exampleserver ~]# su -c 'sudo -l' test
This happens due to the tty enforced by "Defaults requiretty" in /etc/sudoers file.
Defaults !requiretty
To allow any user explicitly:
Defaults:username !requiretty
[root@exampleserver ~]# su -c 'sudo -l' test
sudo: sorry, you must have a tty to run sudo[root@exampleserver ~]#
This happens due to the tty enforced by "Defaults requiretty" in /etc/sudoers file.
How to Fix This Issue?
You need to replace the "requiretty" with "!requiretty" in the /etc/sudoers file to get rid of this issue. However this affects the global sudo configuration. You can allow users of your choice rather than global value though.Defaults !requiretty
To allow any user explicitly:
Defaults:username !requiretty
No comments