PowerShell / PowerShell/Win32-OpenSSH

Invalid MaxPhysicalWindowSize set by sshd

Open
#2,177 4 comments 0 reactions 1 assignee View on GitHub

@tgauth is already working on this.

Since Nov 13, 2023.

Investigate
Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce
  • Install a brand new vanilla windows 2022 server without desktop (in my case in a proxmox VM with default settings, win2022 ISO downloaded from MS website as an evaluation copy).
  • Install OpenSSH with sshd
  • Connect to it from a remote client
  • Check $Host.UI.RawUI.MaxPhysicalWindowSize
Expected behavior

$Host.UI.RawUI.MaxPhysicalWindowSize should be at least as big as the client's size.

Actual behavior

$Host.UI.RawUI.MaxPhysicalWindowSize is smaller than $Host.UI.RawUI.WindowSize, resulting in tools trying to restore termcaps to use the wrong values.

Example: open/close vim.

Error details

Initially posted on the docs repo MicrosoftDocs/Console-Docs#302, but as the bug impacts openssh, reposting it here as well.

Environment data
PS C:\Users\Administrator> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

v9.4.0.0p1-Beta (OpenSSH_for_Windows_9.4, LibreSSL 3.7.3)

Visuals

Example:

  • Check client terminal size
  • Connect to the windows 2022 (no desktop) host
  • Check $Host.UI.RawUI values - Notice MaxPhysicalWindowSize is lower than WindowSize
  • Open/Close vim
  • Check $Host.UI.RawUI again - Notice that vim restored the wrong value, resulting in a broken terminal.
$> stty size
50 145
$> ssh wintest1
PowerShell 7.3.9
PS C:\Users\Administrator> $Host.UI.RawUI

ForegroundColor       : Gray
BackgroundColor       : Black
CursorPosition        : 0,2
WindowPosition        : 0,0
CursorSize            : 25
BufferSize            : 145,50
WindowSize            : 145,50
MaxWindowSize         : 145,50
MaxPhysicalWindowSize : 1008,45
KeyAvailable          : True
WindowTitle           : Administrator: C:\Windows\system32\conhost.exe


PS C:\Users\Administrator> vim
PS C:\Users\Administrator> $Host.UI.RawUI

ForegroundColor       : Gray
BackgroundColor       : Black
CursorPosition        : 0,18
WindowPosition        : 0,0
CursorSize            : 25
BufferSize            : 145,45
WindowSize            : 145,45
MaxWindowSize         : 145,45
MaxPhysicalWindowSize : 1008,45
KeyAvailable          : True
WindowTitle           : Administrator: C:\Windows\system32\conhost.exe


PS C:\Users\Administrator>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.