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
下面的答案并不能让我满意,我想多了解一些情况。有人能解释ssh2_exec()函数调用中的$pty参数吗
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.
它是强迫客户端告诉服务器生成一个PTY还是PTY完全是客户端?就我所知,它附加到一个进程,例如SSHd,这需要调用服务器。而且,当设置为true时,它会模拟默认的shell吗?它是什么?我知道你可以通过xterm,它模拟了一个PTY,这有什么不同吗?在我看来,仿真意味着它不是一个真正的PTY。
That may be a little confusing to read, but I'm trying to grasp this concept. Thank you. I appreciate it.
这可能有点让人困惑,但我想要理解这个概念。谢谢你!我很感激。
1 个解决方案
#1
2
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.
“pty”本质上是某种应用程序或守护进程之间的“管道”(例如,我从事虚拟化工作,我们使用pty为虚拟机提供虚拟终端)。pty有一个“主人”和一个“奴隶”的一面。奴隶的一面是你正常的“终端”项目将使用xterm或ssh,等。主使用什么“东西”提供了数据终端(如果你写进企业,例如当您键入或粘贴文本到一个xterm)就阅读的过程控制主-主那么无论要做什么,它都应该与这些数据——例如在ssh情况下通过网络发送。
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.
这完全与发生的“你的目的”有关。如果您正在运行一个命令是“互动”ssh -说“ssh somemachine使menuconfig”(假设您的主目录是一个linux源代码目录,我们忽视了一个事实,那可能不是),默认是不做一个企业,所以menuconfig可能会失败(正确地操作,至少),因为它是一个“互动”文本程序允许您按键发,等。因此,使用“ssh - t somemachine使menuconfig”将给你的ssh企业。另外,“ssh somemachine”将在默认情况下为您提供一个pty,因为您需要在另一端输入内容。
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.
pty是一个“本地”终端,但是sshd进程将向它提供来自另一端的数据,而您的本地sshd进程将它提供给pty的“主”端。
This page describes what I've tried to say http://lugatgt.org/2009/10/28/ssh-tips-and-tricks-2/
这个页面描述了我想说的:http://lugatgt.org/2009/10/28/ssh- tipandls2/
#1
2
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.
“pty”本质上是某种应用程序或守护进程之间的“管道”(例如,我从事虚拟化工作,我们使用pty为虚拟机提供虚拟终端)。pty有一个“主人”和一个“奴隶”的一面。奴隶的一面是你正常的“终端”项目将使用xterm或ssh,等。主使用什么“东西”提供了数据终端(如果你写进企业,例如当您键入或粘贴文本到一个xterm)就阅读的过程控制主-主那么无论要做什么,它都应该与这些数据——例如在ssh情况下通过网络发送。
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.
这完全与发生的“你的目的”有关。如果您正在运行一个命令是“互动”ssh -说“ssh somemachine使menuconfig”(假设您的主目录是一个linux源代码目录,我们忽视了一个事实,那可能不是),默认是不做一个企业,所以menuconfig可能会失败(正确地操作,至少),因为它是一个“互动”文本程序允许您按键发,等。因此,使用“ssh - t somemachine使menuconfig”将给你的ssh企业。另外,“ssh somemachine”将在默认情况下为您提供一个pty,因为您需要在另一端输入内容。
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.
pty是一个“本地”终端,但是sshd进程将向它提供来自另一端的数据,而您的本地sshd进程将它提供给pty的“主”端。
This page describes what I've tried to say http://lugatgt.org/2009/10/28/ssh-tips-and-tricks-2/
这个页面描述了我想说的:http://lugatgt.org/2009/10/28/ssh- tipandls2/