ssh and "stderr is not a tty - where are you?"

Posted on 2006-04-28
Last Modified: 2013-12-16
I want to apply a sequence of commands to a load of servers. It is a relatively complicated sequence of commands including su-ing as a different user, killing a process, exiting, installing a Slackware package, which has a post-installation script, su-ing as a different user again, starting a daemon, sleeping a couple of seconds and then tailing a log file to check that the daemon is healthy.

To apply the command to many servers, I have a BASH for loop which changes $server and executes the sequence of commands using SSH as follows:

    ssh root@$server "blah; blah; blah"

All I need to do is to paste the root password and I'm in business.

However, one of my commands is throwing up the error: "stderr is not a tty - where are you?". Evidently one of the commands is checking stderr and getting disappointed. Rather than sorting out the command which is the culprit, is there something I can do with SSH to avoid this?
Question by:rstaveley
    LVL 14

    Accepted Solution


    I'd do it the other way around...

    for i in `cat servers.txt`
    cat | ssh root@$server /bin/bash

    But I don't know if that helps at all...

    I'm using ssh in a simular way, but I use ssh-keys in order to not type passwords...

    LVL 43

    Expert Comment

    use -t option to the ssh
    ssh -t root@$server "blah; blah; blah"
    LVL 17

    Author Comment

    That works, Jonas. Many thanks. Oddly enough I still see the "stderr is not a tty - where are you?", but it isn't a show-stopper.

    > I use ssh-keys in order to not type passwords

    I would if I could but I keep losing the argument about that approach with our main admin, who unceremoniously zaps my .ssh/authorized_keys2 entries 8-)
    LVL 17

    Author Comment

    ravenpl, the -t option gets me a warning:

       Pseudo-terminal will not be allocated because stdin is not a terminal.

    ...and doesn't seem to make any difference otherwise.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now