Fix broken scrolling on remote SSH text editors

Note: This issue was fixed by Microsoft in January 2019, and has been rolling out to beta Windows 10 releases.


There can exist incompatible terminal types between the local and remote computers on an SSH connection. This was noticeable for example between an Windows Subsystem for Linux SSH session to a CentOS 6 or 7 server. The issue arises when trying to scroll in a text editor on the remote computer such as nano, emacs or vim among others. The text display would become all scrambled.

Since the Microsoft WSL January 2019 fix takes perhaps a year or more to reach end users, it is worthwhile to provide the community this workaround.

Fix

On the local SSH client PC, make the entries to the problem remote connection(s) as follows in the ~/.ssh/config file on your local PC. This is inside the WSL session for those using WSL.

Host myhost
    RequestTTY yes
    RemoteCommand export TERM=linux && bash

Explanation

RequestTTY yes
opens a pseudo-terminal on the remote server, like the ssh -t option. If you have trouble, try RequestTTY force
RemoteCommand
this should normally have a && bash at the end of the command, assuming you want an interactive SSH session. Otherwise the remote server runs the command and immediately disconnects.

Tags:

Categories:

Written by Michael Hirsch, Ph.D. //

Comments