ssh->sudo tcgetattr: Invalid argument

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am responsible for backing up close to 250 servers and
workstations.  For the servers (mostly debian), I use something like
this (where rsyncSend contains: /usr/bin/rsync $*):

/usr/bin/ssh -pXXXX -q -x -l backup sudo /var/
backups/rsyncSend ...

Recently some CentOS boxes have been thrown into the mix.  With the
above command, I get:

Got remote protocol 1868854643
Fatal error (bad version): sudo: sorry, you must have a tty to run

Reading the man page of ssh, I figure it makes sense to add -t to
create a tty on the remote system:

/usr/bin/ssh -t -pXXXX -q -x -l backup sudo /var/
backups/rsyncSend ...

I get the same error, so decide it's a good idea to add a second -t
since the ssh is not running from a tty on the local host:

/usr/bin/ssh -t -t -pXXXX -q -x -l backup sudo /var/
backups/rsyncSend ...

Now I get a new error:

Got remote protocol 1701274484
Fatal error (bad version): tcgetattr: Invalid argument

I'm stuck at this point.  This only happens on the CentOS servers.
And it only happens if the command is run from a process without a
tty, it works from the command line.  I've disabled selinux on both
ends.  Any ideas?

Thanks in advance,


Re: ssh->sudo tcgetattr: Invalid argument

daoist wrote:
Quoted text here. Click to load it

This is an RHEL 5 change. Cron jobs don't have an associated tty.

You can either edit the /etc/sudoers to comment out the line 'Defaults
requiretty' to allow non-tty connections, which I do *NOT* recommend, or use
service specific keys to access the target as root and restrict the commands
to rsync, like the 'validate-rsync' as described here:

Site Timeline