gpt4 book ai didi

c++ - 将伪 tty 与 ssh 一起使用会导致警告

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:37:14 24 4
gpt4 key购买 nike

我在我的应用程序中使用 ssh,必须将“-t -t”传递给 ssh 才能使其正常工作。否则,我的应用程序的标准输入会受到对 ssh 的调用的干扰。通过 -t -t 强制伪终端使用 ssh 可以避免这个问题,但会导致从 ssh 返回以下模糊的错误消息,尽管应用程序似乎可以正常工作:

tcgetattr: Inappropriate ioctl for device

我想摆脱这条消息以防止它发生而不是仅仅抑制它,但我不确定它为什么会出现以及我应该做什么来防止它。我只在 -t -t 传递给 ssh 时收到消息。

请注意这里提出了类似的问题:

http://www.perlmonks.org/?node_id=664789

ssh 的手册页说:

-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.

最佳答案

可以通过将 -n 传递给 ssh 而不是 -t -t 来解决这个问题。来自 ssh 手册页:

 -n      Redirects stdin from /dev/null (actually, prevents reading from
stdin). This must be used when ssh is run in the background. A
common trick is to use this to run X11 programs on a remote
machine. For example, ssh -n shadows.cs.hut.fi emacs & will
start an emacs on shadows.cs.hut.fi, and the X11 connection will
be automatically forwarded over an encrypted channel. The ssh
program will be put in the background. (This does not work if
ssh needs to ask for a password or passphrase; see also the -f
option.)

所以这是解决标准输入从调用进程获取并提供给 ssh 的问题的另一种方法,但是,我想了解如何在使用 -t -t 时避免警告。

关于c++ - 将伪 tty 与 ssh 一起使用会导致警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1495776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com