What magic did openssh do to handle programs like VIM?

Darren Tucker dtucker at zip.com.au
Mon Feb 10 19:59:41 EST 2014


On Mon, Feb 10, 2014 at 7:39 PM, Aaron Lewis <the.warl0ck.1989 at gmail.com> wrote:
> I'm trying to write my own remote shell program,
[...]
> 2. If I run command like VIM, it doesn't run.
>     And buttons like "<ESC>:q" won't work
>
> Can someone enlighten me about what SSH did, so it all works perfectly?

Pseudo terminals: http://en.wikipedia.org/wiki/Pseudo_terminal.  ssh
asks sshd for one when you run an interactive shell (eg "ssh
yourserver") or you use the -t flag.  You can run vim via ssh without
a pty and it'll behave like your application: "ssh server vim
somefile".

If you can find a copy of Stevens' Advanced Programming in the Unix
Environment it's got a chapter on PTYs that's pretty good.  Failing
that, take a look at the openpty man page and the code in openssh's
sshpty.c.

if you don't have openpty then your task just got harder because it's
quite platform-specific; take a look in openbsd-compat/bsd-openpty.c.

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.


More information about the openssh-unix-dev mailing list