执行远程命令时出现 SSH 错误:“stdin: is not a tty" [英] SSH error when executing a remote command: "stdin: is not a tty"
问题描述
我正在尝试使用 ssh 连接到机器一,然后使用 ssh 连接到另一台机器.但是得到这个错误:
I'm trying to connect to machine one with ssh and then connect to another machine two with ssh. But get this error:
ssh user@computerone.com 'ssh otheruser@computertwo.com'
stdin: is not a tty
推荐答案
登录到 shell 时,远程主机假定连接是由人类用户完成的.因此,有理由期望他们可以控制客户端上的标准.也就是说,用户正在通过键盘在终端上进行输入.如果远程主机检测到用户不是人类(因为输入的不是终端 - tty,而是另一个进程),它可能会警告用户这种意外情况.
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.
所讨论的不当行为的演示以及如何避免它(man ssh
并查找 -t 以获得更全面的解释).
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
...和错误:
$ 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"
如果远端没有配置 DNS 别名,则使用 IP 地址,例如 192.168.0.11.
Use IP addresses such as 192.168.0.11 if DNS aliases are not configured on the remote end.
这篇关于执行远程命令时出现 SSH 错误:“stdin: is not a tty"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!