OpenSSH via powershell - vi turns prompt blue

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.

p0lar_bear

Posted 2018-06-25T01:20:44.280

Reputation: 419

Does it happen when you use another client (e.g. PuTTY) to connect? – Kamil Maciorowski – 2018-06-25T05:09:23.897

Are you using vim, neovim, nvi, or ex-vi? – user1686 – 2018-06-25T12:51:27.850

@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 – 2018-06-28T15:23:11.067

@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 – 2018-06-28T15:23:24.057

Answers

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.

Kaveh Vahedipour

Posted 2018-06-25T01:20:44.280

Reputation: 124

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. https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

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 – 2018-06-28T15:34:15.290

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. – Kaveh Vahedipour – 2018-06-28T15:39:15.243

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 – 2018-06-28T16:07:03.937

I'd really appreciate if you would accept my answer, then. – Kaveh Vahedipour – 2018-06-28T16:08:29.880

1No. 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 – 2018-06-28T16:13:34.333

...And I can't undo the vote unless you edit the answer. Figures. :/ – p0lar_bear – 2018-06-28T16:14:18.500

With all due respect, I really don't see, where the answer is bashing for bashing windows. I am 47 and beyond those years. The first line just says that powershell is not a terminal emulator. It is not meant to be one, ever. The rest is "consider using ...". Anyway many thx. – Kaveh Vahedipour – 2018-06-28T16:16:40.450

1Thank 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 – 2018-06-28T16:28:40.263

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.

zadjii

Posted 2018-06-25T01:20:44.280

Reputation: 11