Skip to content
sparky edited this page Sep 14, 2010 · 5 revisions

Welcome to the OpenSSH-LINEMODE wiki!

LINEMODE was originally a telnet protocol option negotiated between a telnet client and server that allows the client to do local input line editing. This allows fast input processing without waiting for remote character echoes, and saves on packet and byte counts in a typical terminal session. The feature has been supported in BSD-based kernels and telnet/telnetd since 1989. Corresponding support for Linux was largely ignored, but will be available in an upcoming release; the pending patch is available here:

kernel patch

glibc patches (for <termios.h> and such) will also be needed to expose these features to applications.

Note: some folks question whether this feature has any relevance today in 2010, 21 years after the fact. Personally, I make heavy use of the ConnectBot ssh client on my Android G1 phone, and I’m often traveling to places where only GPRS service is available. Character-at-a-time echoing is tortuously slow in these cases, and also I’m frequently roaming and paying exorbitant per-byte data roaming fees. While it would be great if some consumers’ rights organization kicked all these telco’s collective behinds and made them charge tariffs more in line with their actual cost of providing service, that’s not likely to happen any time soon. So IMO, yes, Linemode is still relevant and necessary today.

The original BSD telnet/telnetd code appears to have been forked off in a number of different repositories, including the netkit package and also the MIT Kerberos 5 source. A patch for the netkit code to correctly support LINEMODE on Linux is available here

netkit patch

That patch simply fixes the existing code to compile and run correctly on Linux using the new kernel support, but this support is of somewhat limited usefulness these days because the most common command shells no longer used tty cooked mode for input. Instead, they also do character-at-a-time input to support richer editing commands, command history, and command completion.

The OpenSSH code in this repo has been enhanced to not only support basic cooked mode input, but also local command history. Support for local/remote hybrid command completion is partially done, but will require additional cooperation from the remote command shells.

A partial patch for GNU bash / readline is available here

readline patch

Full support for command completion is still under way. A simple protocol needs to be defined for this purpose, so it may be implemented uniformly across the various input-editing libraries that support command-completion. (e.g. GNU readline, BSD libedit, etc…) Currently the approach is for the library to detect that the tty has EXTPROC enabled, and turn off most of its input processing features, leaving them to be performed by the remote client. In addition, if command-completion is supported, the library should set the VEOL character to TAB. The client will detect that remote command-completion is supported when VEOL is thus set. When the client reads a completion character from the keyboard, it will send the current line (with trailing TAB) to the remote session, and the remote lined editing library should respond with a list of possible completions. The list must be delimited by (TBD) to let the client know it’s not regular tty output. The client will then feed this list into its local command-completion code for display/selection/etc.

Clone this wiki locally