dp5657087 2013-01-05 18:06
浏览 755
已采纳

理解ssh2_exec()中的PTY参数

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.

  • 写回答

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/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条