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

1

26

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
Reames answered 18/9, 2012 at 15:34 Comment(2)
Try adding -t flag to first ssh. By the way, since your question is not related to programming, it might be more appropriate at superuser.comSocha
@Socha You have reason. With -t option run.Reames
F
31

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.

Franzen answered 21/9, 2012 at 19:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.