Can anyone explain the $pty argument in ssh2_exec&

2019-08-02 09:55发布

问题:

I've been using ssh2_exec for a while now to build an admin panel and deployment system for our workplace and so far was very successful up to when i tried to use it on another server than the local server.

I keep getting "stdin: is not a tty" and i have been looking all over the web to get this message to go. I understand that the issue is that ssh2_exec is not an interractive terminal per se and something on the server i'm connecting to is probably trying to check for an input method of some sort... At least thats what i seem to understand.

I've scoured google for 1h30 trying to find posts relative to php's ssh2 implementation which works fine for my usage for now but was never able to find out how to fix this although i think i might have an idea.

There is a $pty argument(3rd) to ssh2_exec() but the docs do not tell us what it seems to do. Is anyone familliar with it and knows how to use this parameter and if it might actually fix the problem i might have?

回答1:

You've hit upon your answer. Setting the $pty argument to true should be the same as passing the '-t' option to the ssh command: it tells the client to open a pseudo-terminal (a.k.a "pty", which comes from "pseudo-tty"; the "tty" comes from "teletype") and pretend to be interactive.



标签: php ssh