I'm pulling my hair out over this. I've looked over all of the google results for /dev/tty : no such device or address, none of them apply to what I am doing / none of the solutions are successful.

I have a script that ssh'es into another machine (using public keys) and runs itself (with different parameters - it doesn't loop). Call this rpmInstallScript.bash

At one point in the script, it runs rpm -ivh to install some RPM packages. During the install of one of these packages, a file is put in /var/tmp called rpm-tmp.[6 random characters]

This file is a script, and I guess it's executed at some point during the rpm install.

In the script, there are multiple occurrences of

echo [something] > /dev/tty 


echo [something] | tee [something] > /dev/tty.

All of these occurrences fail with /dev/tty: no such device or address. If I ssh into the machine manually and either rpm the packages myself, run the rpm-tmp script or run rpmInstallscript.bash, it works fine.

I am connecting to the remote machine with ssh -t, therefore there should be a tty, correct?

I don't see why this isn't working, especially because doing it manually, even without the -t option, works fine. The only thing I can think of is that it's not an interactive session - but /dev/tty should still exist, correct?

Edit - the error results from :

ssh -t root@[machine] -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null <<DONE

where rpmInstallScript.bash runs rpm -ivh, the resulting script placed in /var/tmp uses >/dev/tty - this is what fails

Edit again : using -tt gives :

tcgetattr: Inappropriate ioctl for device

Only when running from a script - manually running ssh -tt and then echo test >/dev/tty works fine.

I can only assume this is a failure to force-create a tty.

Is there any other way to 'generate' a tty? Can I just spoof it by making a file called /dev/tty?

  • The -t option should have solved this. Try putting set -x at the beginning of the script, so you can see all the things it does. Maybe something is checking an environment variable like $TERM and disconnecting from the terminal when this isn't set.
    – Barmar
    Jun 9, 2016 at 19:52
  • I know what it's doing - that's not the problem. It's trying to send output to /dev/tty. The issue is that it's claiming the device doesn't exist Jun 9, 2016 at 20:08
  • I know that. I'm hoping that you'll see something before that which explains how it's getting disconnected from the terminal.
    – Barmar
    Jun 9, 2016 at 20:08
  • ah - I see what you mean, I'll give that a go Jun 9, 2016 at 20:09
  • If you're still having trouble, please edit your question to include the relevant parts of this script.
    – Kenster
    Jun 10, 2016 at 11:56

1 Answer 1


Try -tt to see if it works.

From ssh man page,

Multiple -t options force tty allocation, even if ssh has no local tty.

  • Edited the post - this failed with another [related] error Jun 10, 2016 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .