Getting stty: standard input: Inappropriate ioctl for device when using scp through an ssh tunnel

Per the title, I'm getting the following warning when I try to scp through an ssh tunnel. In my case, I cannot scp directly to foo because port 1234 on device foo is being forwarded to another machine bar on a private network (and bar is the machine that is giving me a tunnel to 192.168.1.23).

$ # -f and -N don't matter and are only to run this example in one terminal
$ ssh -f -N -p 1234 userA@foo -L3333:192.168.1.23:22
$ scp -P 3333 foo.py ubuntu@localhost:
ubuntu@localhost's password:
stty: standard input: Inappropriate ioctl for device
foo.py                                          100% 1829     1.8KB/s   00:00

Does anyone know why I might be getting this warning about Inappropriate ioctl for device?


I got the exact same problem when I included the following line on my ~/.bashrc:

stty -ixon

The purpose of this line was to allow the use of Ctrl-s in reverse search of bash.

This gmane link has a solution: (original link dead) => Web Archive version of gmane link

'stty' applies to ttys, which you have for interactive login sessions. .kshrc is executed for all sessions, including ones where stdin isn't a tty. The solution, other than moving it to your .profile, is to make execution conditional on it being an interactive shell.

There are several ways to check for interecative shell. The following solves the problem for bash:

[[ $- == *i* ]] && stty -ixon

Got the same issue while executing the script remotely. After many tries didn't get any luck to solve this error. Then got an article to run a shell script through ssh. This was an issue related to ssh, not any other command. ssh -t "command" -t will allocate a pseudo TTY to the ssh and this error won't come.