×

【已解决】Pseudo-terminal will not be allocated because stdin is not a terminal.

Falcon 2022-10-02 views:
摘要

正在生成中……

在终端下执行ssh命令,登录并执行命令用ssh到另一台主机,如:

ssh root@n1 ssh hk

会返回错误信息

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

Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-105-generic x86_64)

....

可以看到登录到另一台主机是成功的,但是不能进行交互。也就是不能继续进行输入,原因在于这个错误:Pseudo-terminal will not be allocated because stdin is not a terminal.

直译过来就是 伪终端不会被分配,因为标准输入流不是一个终端,云里雾里,结果就是等待输入的那头没办法得到输入的,但可以强制给输入流分配伪终端,stackoverflow如是说

Try ssh -t -t(or ssh -tt for short) to force pseudo-tty allocation even if stdin isn't a terminal.

于是上面的命令写成

ssh -tt root@n1 ssh hk

ssh手册的解释:

-T      Disable pseudo-tty allocation.

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

 

本文收录于