Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH error when executing a remote command: "stdin: is not a tty"

Tags:

I'm trying to connect to machine one with ssh and then connect to another machine two with ssh. But get this error:

ssh [email protected] 'ssh [email protected]'  stdin: is not a tty 
like image 374
Jhonathan Avatar asked Sep 18 '12 15:09

Jhonathan


People also ask

Does SSH use TTY?

When you run ssh without a command just to login, a pseudo tty is automatically allocated. But if you specify a command to execute on the ssh command line, by default, ssh does not allocate a pseudo tty. You need to force it to allocate one if you want to run commands such as top or screen.

What is stdin and tty?

/dev/tty is the controlling terminal for the current process. STDIN is the current input. If you redirect, e.g., perl script.pl <myfile.txt.


1 Answers

When logging into a shell, the remote host assumes that the connection is done by a human user. Therefore, it is reasonable to expect that they have control over the standard in on the client. That is to say, the user is giving input on a terminal through the keyboard. If the remote host detects that the user is not human (because the input is not a terminal - tty, but another process), it may warn the user about this unexpected condition.


A demonstration of the discussed misbehavior and how to avoid it (man ssh and look for -t for a more thorough explanation).

$ ssh -t genja.org 'ssh raptor.lan hostname\; uptime' host: genja.lan  raptor  21:17:27 up 3 days, 15 min,  1 user,  load average: 0.00, 0.00, 0.00 Connection to genja.org closed.  $ ssh genja.org uptime  host: genja.lan   21:17:43 up 12 days, 17:40,  1 user,  load average: 0.30, 0.08, 0.02 

...and the error:

$ ssh  genja.org 'ssh raptor.lan hostname\; uptime' host: genja.lan  Permission denied (publickey,keyboard-interactive). 

You may want to make a tunnel instead:

ssh -L 4444:raptor.lan:22 genja.org 

Then, on a different terminal:

ssh -p 4444 localhost will give you a conenction straight to "raptor.lan" 

Use IP addresses such as 192.168.0.11 if DNS aliases are not configured on the remote end.

like image 132
Ярослав Рахматуллин Avatar answered Sep 21 '22 08:09

Ярослав Рахматуллин