I have configured
sudo to run without a password, but when I try to
ssh 'sudo Foo", I still get
sudo: sorry, you must have a tty to run sudo.
Why does this happen and how can I work around it?
That's probably because your
Red Hat have acknowledged the problem and it will be removed in future releases.
If changing the configuration of the server is not an option, as a work-around for that mis-configuration, you could use the
To minimise the impact, you could invoke it as:
Note that since the output of the remote command will go to a terminal, that will still affect its buffering (which will be line-based for many applications) and bandwidth efficiency since
Also, note that it means the remote command cannot detect end-of-file on its stdin and the stdout and stderr of the remote command are merged into a single stream.
So, not so good a work around after all.
If you've a got a way to spawn a pseudo-terminal on the remote host (like with
For example, with
(here assuming the login shell of the remote user is Bourne-like).
By default, SUDO is configured to require a TTY. That is, SUDO is expected to be run from a login shell. You can defeat this requirement by adding the
If you want to perform this globally, modify