2013-01-05 18:06
浏览 519


The answer to the following doesn't satisfy me, I wish to know a bit more about what's going on. Can anyone explain the $pty argument in ssh2_exec() function call

Does it force the client to tell the server to spawn a PTY or is the PTY totally client-sided? As far as I know it's attached to a process such as a SSHd for example, which would require a call to the server. Also, when set to true does it emulate the default shell? What is it? I know you can pass xterm for example, which emulates a PTY, is this any different? Emulation implies it's not a real PTY from my perspective.

That may be a little confusing to read, but I'm trying to grasp this concept. Thank you. I appreciate it.

图片转代码服务由CSDN问答提供 功能建议

以下答案并不能让我满意,我希望了解更多有关正在发生的事情。 n 任何人都可以在ssh2_exec中解释$ pty参数 ()函数调用

它是否强制客户端告诉服务器产生PTY或者是完全客户端的PTY? 据我所知,它附加到 例如SSHd这样的进程,需要调用服务器。 另外,设置为 true 时是否模拟默认shell? 它是什么? 我知道你可以传递 xterm ,例如模仿一个PTY,这有什么不同吗? 从我的角度来看,仿真意味着它不是一个真正的PTY。

这可能有点令人困惑,但我正试图掌握这个概念。 谢谢。 我很感激。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanhuchang5056 2013-01-05 18:48

    A "pty" is essentially a "pipe" between some sort of application or daemon (for example, I work on virtualization, and we use a pty to provide the virtual terminal for a virtual machine). A pty has a "master" and a "slave" side. The slave side is what your normal "terminal" program would use - xterm or ssh, etc. The master is used by whatever "thing" provides the data into the terminal [and if you write into the pty, e.g. when you type or paste text into an xterm] it gets read by the process controlling the master - the master then does whatever it should do with such data - e.g. sending it across the network in an ssh case.

    It is completely to do with what happens "your end". If you are running a command that is "interactive" over ssh - say "ssh somemachine make menuconfig" [assuming your home directory is a linux source directory - we'll ignore the fact that it probably isn't], the default is to not make a pty, so menuconfig will probably fail [to operate correctly, at least] because it's a "interactive" text program that allows you to press keys to mover around, etc. So using "ssh -t somemachine make menuconfig" will give your ssh a pty. Alternatively, "ssh somemachine" will give you a pty by default, since you are expected to type things into the other end.

    The pty is a "local" terminal, but the sshd process will provide it with data from the other end, and your local sshd process feeds it into the "master" side of the pty.

    This page describes what I've tried to say http://lugatgt.org/2009/10/28/ssh-tips-and-tricks-2/

    解决 无用
    打赏 举报

相关推荐 更多相似问题