6

When i use heredoc and put all the commands inside heredoc as,

ssh -t -i master.pem cloud-user@$1 <<EOSSH
sudo service x restart
sudo service y restart
EOSSH

it throws error as,

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

When i add another -t option, it works good,

ssh -t -t -i master.pem cloud-user@$1 <<EOSSH
sudo service x restart
sudo service y restart
EOSSH

What does pseudo-terminal mean, in the context of a ssh session?

stdin is not a terminal - Doesn't bash provide a stdin terminal to the ssh client?

What does -t option mean and how is -t -t different from -t?

4

As explained in man ssh:

-t         Force pseudo-tty allocation. This can be used to execute arbi‐
           trary 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.

3
  • hi terdon, ssh server reads the stream of input via a socket and runs them as commands. It just need a tcp/ip socket. when and why does the ssh server need a terminal?
    – user93868
    Jun 16 '15 at 15:26
  • @MadhavanKumar oh, it's sudo that needs it to get the password
    – terdon
    Jun 16 '15 at 15:33
  • It may not need a terminal. Ssh is printing the pseudo-tty notice because it was run with "-t". It has no idea whether the commands run on the remote server need a tty or not.
    – Kenster
    Jun 18 '15 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy