Recently a colleague of mine was working on a bash script to copy a script to a group of servers, run the script and display the output.  The basic structure of the script was:

for host in $(host_list); do
  echo "Host = $host"
  scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no check_script.rb user@${host}:/tmp/check_script.rb
  ssh -tt -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@${host} 'chmod +x /tmp/check_script.rb'
  ssh -tt -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@${host} 'sudo ruby check_script.rb'

When he attempted to run his script, it was failing after copying the script to the first remote host with the error tcgetattr: Inappropriate ioctl for device.  A google search turned up a bunch of results, but nothing helpful enough to resolve the issue.

The issue turns out to be the ssh command requesting a TTY and erroring out because it is unable to get one.  Removing the -tt option from the ssh commands resolves the issue.

From the man page for ssh:

-t    Force pseudo-tty allocation. This can be used to execute arbitrary
      screen-based programs on a remote machine, which can be very
      useful, e.g. when implementing menu services. Multiple -t options
      force tty allocation, even if ssh has no local tty.