1
1
Summary
There seems to be a bug in Win32-OpenSSH that prevents colors to be shown in certain terminal emulators such as PuTTY and mintty.
Win32-OpenSSH seems to replace the color escape sequence "\033[32m\033[40mtest" by "\033[0;39;24;27;32;40;mtest" and the problem seems to be the last semicolon before the m. Removing this semicolon, the colors are displayed correctly.
Details
I installed Win32-OpenSSH-Win64 (version 0.0.24.0) according to https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH.
I set
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShell="C:\Program Files\GIT\bin\bash.exe"
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShellCommandOption="-c"
Logging into my machine with
ssh localhost
I do not get color output with PUTTY, and not with "Git Bash for Windows" but I do get colors with the native "cmd.exe" and with "Bash on Ubuntu on Subsystem for Linux" connecting to the same local server.
The problem seems to be related to unusual escape sequences. Logging all session output in PuTTY shows escape sequences that are terminated by a semicolon: "\033[0;39;24;27;32;40;mtest" and PUTTY does not seem to be able to handle them. Escape sequences without the final semicolon, e.g., "\033[0;39;24;27;32;40mtest" are handled correctly by PUTTY.
Those unusal escape sequences seem to be introduced by Win32-OpenSSH. In contrast, the Bitvise SSH Server produces the escape sequence "\033[32m\033[40mtest".
3PuTTY actually interprets them correctly -- an empty parameter is equivalent to 0, which unfortunately happens to mean "reset all formatting". (In other words,
\033[0;39;24;27;32;40;mtest
is equivalent to\033[0;39;24;27;32;40;0mtest
which collapses down to\033[0mtest
.) I suggest sending a bug report to the WSL developers. – user1686 – 2017-12-29T10:24:30.863So the issue seems to be with OpenSSH. Is there a way to prevent OpenSSH from adding the final semicolon? – David – 2017-12-29T15:35:46.233
Again, sounds like a bug in the Windows' OpenSSH port. (And the fact that WSL shows colors would probably indicate a bug in WSL as well.) – user1686 – 2017-12-29T16:00:27.327
see GitHub issues https://github.com/PowerShell/Win32-OpenSSH/issues/1005 and https://github.com/Microsoft/console/issues/44 and
– David – 2017-12-29T18:03:14.600