1

I'm on Windows 10, using Win32-OpenSSH via Powershell to connect to a CentOS 7 machine on my network.

If I launch vi on a new file, or on occasion open other files, any and all new text in my window turns blue.

enter image description here

This continues until I close the Powershell window.

Any idea why this is happening, and if there's a workaround that doesn't involve using a different ssh client or environment? I understand I can just use a "proper" terminal emulator like PuTTYm, but my question is whether or not there's a known fix for this particular scenario.

4
  • Does it happen when you use another client (e.g. PuTTY) to connect? Jun 25 '18 at 5:09
  • Are you using vim, neovim, nvi, or ex-vi?
    – user1686
    Jun 25 '18 at 12:51
  • @KamilMaciorowski I haven't tried another terminal emulator. However, this doesn't happen when I'm using the machine directly, i.e. by connecting to it via the Hyper-V manager.
    – p0lar_bear
    Jun 28 '18 at 15:23
  • @grawity I have no idea off the top of my head. As the buffer shows I'm executing vi and this is a barely-modified CentOS 7 minimal install, I'm assuming this is just vanilla vi. And I do remember trying to execute vim and getting a "command not found".
    – p0lar_bear
    Jun 28 '18 at 15:23
0

Powershell is not a terminal emulator and thus will get all excited about the according remote flow control and visual control character that.

As long as you are planning to use ssh in a script, you wouldn't care less about fishy colours, they will not show in the output. What does possible happen though is that you end up with some garbled characters. Like

However, if this is an interactive shell, consider using a terminal emulator like putty.

8
  • I'm more than aware that the Windows console isn't and does not attempt to emulate a VT100 TTY. However, Microsoft's flavor of the OpenSSH client includes a VT100 interpreter and it's said that it can handle most TTY scenarios, with the caveat that some interactive *nix applications have some issues. github.com/PowerShell/Win32-OpenSSH/wiki/… The question was asking if there was any sort of known workaround for this, i.e. if other WinOpenSSH users encountered this, or if it's happened to other TTY emulators.
    – p0lar_bear
    Jun 28 '18 at 15:34
  • The problem is not the ssh client, i.e. openssh. The problem is that cmd or powershell receive the control signs that manipulate the colors etc. in the client terminal like \[\e]0; and instead of turning the font green just screws up. In other words, if you used the openssh client in its own UI window you're gonna be fine. Btw, the same garbage will show if you use plink.exe from PuTTY in a cmd shell. I'd really appreciate, if you accepted the answer, if this helped you, as some jackass decided to downvote the correct answer. Jun 28 '18 at 15:39
  • It's no secret that Windows and *nix historically don't interoperate well. Microsoft is aware of this and they have a fork of OpenSSH made specifically for use with cmd/powershell, which I am using. This is indeed an issue with this specific ssh client, as the integrated VT100 interpreter likely isn't handling some control codes in a fashion that result in the expected output. As you can see in my screenshot, I'm not getting "garbage" output as if I was running a script or binary intended for an ANSI terminal with no further processing.
    – p0lar_bear
    Jun 28 '18 at 16:07
  • 1
    No. In addition, said "jackass" was me, thank you, as this answer reads much like bashing Windows for the sake of bashing Windows. Your attitude towards the downvote (i.e. calling me a jackass and asserting that your answer is THE correct answer) reinforces this perception. Though on reflection, I will concede I wasn't clear. I will reverse the downvote because I realize I need to rephrase my question as I wanted insight as to why this happens, and to know if there was a workaround that wasn't "just use PuTTY lol", and it seems my intent wasn't conveyed.
    – p0lar_bear
    Jun 28 '18 at 16:13
  • 1
    Thank you, that answer reads much better. I will consider accepting this as the answer if nobody else comes along soon and posts an answer that has a workaround/fix. Apologies for the crossed signals.
    – p0lar_bear
    Jun 28 '18 at 16:28
1

this was apparently a bug in the Windows Console Host.

The relevant discussion is here on the Powershell-OpenSSH github repo.

According to the maintainers, Windows 1809 (the 2018 Fall update) has the fix for this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.