...and while we're at it, are you sure you need PTY at all?
Pseudo terminal is only needed if you intend to spawn in the remote
session a program which actively expects to be connected to a terminal
device, and such programs are in most cases are interactive -- such as
full-screen text editors (like nano, Vim, Emacs etc) or, say, chat
clients like irssi or mcabber and so on. If you merely want to spawn a
program which prints something to its standard output streams, and you
want to grab that output, not only you do not need to allocate a PTY to
run that program, but doing that might actually complicate matters.
To explain it in more simple words, suppose you need to run `git log`
on a remote machine and grab its output. If you allocate a PTY for
that command to run, it will detect it's connected to a terminal and
enable colouring of its output -- assuming it's interacting with a
human operator. What's worse, it will even spawn the so-called
"pager" (usually `less` or `more`) to pipe its output through it.
Conversely, if it will detect it's not connected to a termnial, it will
go to a "no-frills" mode and merely output plain uncoloured data into
its stdout; no pager will be run, of course.
TL;DR
Please make sure you do really need a PTY to run your program.