Repository navigation
Serve interactive shells from the SSH server - #24
Merged
Merged
Conversation
ServerSession handled only exec and subsystem channel requests and refused every other one. A client that opens a shell sends pty-req first, so Channel.request_shell() against an ssh.Server failed with "Failed to request PTY". Server gets an on_shell callback. When it is set, the server accepts pty-req, keeps the terminal on the channel, and gives it to on_shell(session, channel, pty) with the shell request. pty is a PtyRequest with term, cols, rows, width_px and height_px, or None when the client asked for no terminal. The application accepts or rejects the shell request as for exec. Without on_shell the server refuses both requests, as before. on_shell comes after on_session_close in the Server parameters, so callers that give on_session_close by position keep working.
A client sends window-change when the terminal of its shell changes size. The server refused it, and the client had no way to send one. ServerChannel gets an optional on_window_change(channel, cols, rows). The server gives each window-change to it, also while another request on the channel waits for the application. The client wants no reply. Channel gets change_pty_size(cols, rows). libssh sends window-change as a channel request, which waits for the reply of a request still in flight, so the client sends it once the shell runs. On a shell without a terminal it sends nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ServerSession handled only exec and subsystem channel requests and refused the rest. A client that opens a shell sends pty-req first, so Channel.request_shell() against an ssh.Server failed with "Failed to request PTY". A test server could not stand in for a device that a client drives through a shell, like IOS XE, where the StratoWeave CLI adapter keeps one shell open per device.
Server gets an optional on_shell(session, channel, pty). When it is set, the server accepts pty-req and gives the terminal to on_shell with the shell request: a PtyRequest with term, cols, rows, width_px and height_px, or None when the client asked for no terminal. The application accepts or rejects the shell as for exec. Without on_shell the server refuses both requests, as before. on_shell comes after on_session_close in the Server parameters, so callers that give on_session_close by position keep working.
The second commit adds terminal size changes. ServerChannel gets an optional on_window_change(channel, cols, rows), and Channel gets change_pty_size(cols, rows) to send one. The client sends it once the shell runs, because libssh sends window-change as a channel request, and that would take the reply of a shell request still in flight.
The new loopback tests open a shell with and without a terminal, check that a server without on_shell refuses it, close the channel in the middle of a command, and change the terminal size. The full suite, the write-barrier checker run and the OpenSSH interop tests pass.