Edit: I should have mentioned in my original question that I was using MacPorts SSH client, as it turned out there were two root causes. See my own answer below.

When I SSH into my OSX machine, it's not setting the locale properly:


This should be using a UTF-8 locale. It should look like this:


I'm running OSX 10.11.6 (El Capitan), and I've enabled the SSH server in System Preferences.

I'm using putty as a client on my Windows machine. When I use the same putty configuration to connect to a Linux server, the locale information is fine.

When I run a local terminal on the OSX machine, locale is fine. If I then ssh localhost, I have the same problem: no locale is set.

It seems that my OSX SSH server is ignoring or discarding the locale information from the client. I have the following in my (unmodified) /etc/ssh/sshd_config:

AcceptEnv LANG LC_*

To the best of my knowledge, that's all that's required.

My putty configuration is sending TERM=xterm-256color, which is being honored; it's only the locale information that isn't working, and to reiterate, it happens when I ssh localhost from OSX to itself, so I don't think putty is the issue here.

I will not accept answers that suggest setting the locale in my .profile; there are plenty of answers on here suggesting that, but it's a hack, not a solution.


Turns out there were two problems here:

First, PuTTY wasn't actually sending any locale information. Apparently the Linux servers were configuring the locale automatically, or based on TERM or something. I fixed PuTTY by configuring environment variables for it to send:

PuTTY locale configuration

Second, I'm using MacPorts (updated question since this was missing in the original), and MacPorts ssh does not send locale variables. I can't imagine why MacPorts configures SSH this way, but I had to add the following to /opt/local/etc/ssh/ssh_config:

Host *
  SendEnv LANG LC_*

That really ought to be the default MacPorts config; it's the default on any standard Linux system, and it's even the default in OSX's own SSH. Figured out that MacPorts was part of the problem when SSH from Linux to OSX did set the locale.

I've filed a ticket with MacPorts suggesting the default be changed.

|improve this answer|||||

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .