libssh lacks terminal modes support, the OpenSSH sends tty modes to remote side, while libssh does not.
Without terminal modes, some applications (e.g. Karaf OSGi container) will sends incorrect control sequences perversely (e.g. client requires CRLF, but sends just LF).
It's very easy to reproduce the problem by using our Mac app -- SSH Shell, please see attached screenshots for before/after patch applied.
This patch based on master branch, we added a new function ssh_channel_request_pty_size_modes for sending tty modes. Compare to ssh_channel_request_pty_size, this function takes an extra parameter with type struct termios, and convert it into terminal modes data that remote side could parse.
The patch was tested under MacOS, but it should also work in other platform. The function would be disabled if the platform does not have termios terminology.
Note: we only implement terminal modes in client-side, the server-side still missing.
- reference **
- RFC4254 - Encoding of Terminal Modes
- OpenSSH relate implementation: