Skip to content

How to get terminal dimensions from a terminal request #112

@h3x4d3c1m4l

Description

@h3x4d3c1m4l

Hi all,

For my photobooth project, I'm currently working on a control server in which I'd like in incorporate a SSH server for management and status purposes. I'm currently stuck in getting the terminal dimensions from the pty-req package.

My channel request handler looks as follows:

server.ChannelRequest += (channel, e) =>
{
    if (channel is SshChannel sshChannel)
    {
        if (e.RequestType == ChannelRequestTypes.Terminal)
        {
            // TODO: Find the terminal dimensions
            // I expected e.Request to be of type [TerminalRequestMessage] instead of type [ChannelRequestMessage]
            // which contains the fields I need.
            
            // Accept PTY allocation
            e.IsAuthorized = true;
        }
    }
}

I would have expected to get an object of type TerminalRequestMessage with the following fields (from RFC 4254):

      byte      SSH_MSG_CHANNEL_REQUEST
      uint32    recipient channel
      string    "pty-req"
      boolean   want_reply
      string    TERM environment variable value (e.g., vt100)
      uint32    terminal width, characters (e.g., 80)
      uint32    terminal height, rows (e.g., 24)
      uint32    terminal width, pixels (e.g., 640)
      uint32    terminal height, pixels (e.g., 480)
      string    encoded terminal modes

(From: https://www.rfc-editor.org/rfc/rfc4254#section-6.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions