【问题标题】:Using pseudo tty with ssh results in warning将伪 tty 与 ssh 一起使用会导致警告
【发布时间】:2009-10-04 06:06:29
【问题描述】:

我在我的应用程序中使用 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.

【问题讨论】:

    标签: c++ ssh


    【解决方案1】:

    可以通过将 -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.)
    

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

    【讨论】:

    • 你搞清楚了吗?我也想理解这一点,因为在我的情况下(略有不同)我不能使用-n。我在serverfault.com/questions/851186 询问过,如果合适,请随时在此处而不是此处回答。
    • @Davide 我在服务器故障上支持你。这是不久前,我不记得避免 -t -t 警告,但我可能记错了。如果您在那里得到很好的回应,请在此处更新您的评论。
    猜你喜欢
    • 1970-01-01
    • 2019-09-19
    • 2014-01-28
    • 1970-01-01
    • 2019-12-31
    • 2019-08-04
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多