Вопрос

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.

Это было полезно?

Решение

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/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top