Menu

Why Non-ASCII Input Breaks over SSH: Locales, SendEnv and the `env` Request
📰

Why Non-ASCII Input Breaks over SSH: Locales, SendEnv and the `env` Request

DEV Community: rust·c-wind·17 days ago
#2v9SQrgh
#devtorust#devto#dev#locale#lang
Reading 0:00
15s threshold

Originally published on MistLab . Part 4 of Building an SSH Terminal .

Part 4 of "Building an SSH Terminal". Code excerpts are from MistTerm v1.2.26, an open-source (AGPL) SSH terminal client by MistLab; they are trimmed

TL;DR

Garbled non-ASCII input over SSH usually means the remote program runs in the POSIX/C locale, so line editors such as readline treat each byte as a character. The locale reaches the server through the RFC 4254 env request, which sshd accepts only for variables listed in AcceptEnv . Upstream OpenSSH sends no variables by default; Debian-family packages add SendEnv LANG LC_* and the matching AcceptEnv . The fix is to forward a valid UTF-8 locale and to allow it on the server.

A common SSH puzzle goes like this. Output in Chinese, Japanese or with accented letters displays fine. But when you type such characters at a bash or mysql prompt, the line fills with garbage, or Backspace deletes half a character. The terminal is not at fault.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.