View international characters in SSH sessions

Jul 14, '09 07:30:42AM

Contributed by: Aikinai

Files with Japanese names that show up fine when I'm in the local terminal, all turn into ???? when I ssh in from my laptop. It's because the locale of the remote sessions is ignoring the default locale and encoding of my local terminal. My local terminal defaults to "en_US.UTF-8," while the ssh sessions are something called "C," which apparently doesn't support Unicode.

One solution I've discovered is to to edit the ssh_config and sshd_config files so that the client sends the language environment variables, and the server accepts them. I've created two commands you can run in Terminal to achieve this: On the server, you should run:

sudo sh -c 'printf "\n\n# Accept language environment variables\nAcceptEnv LANG LC_*" >> /etc/sshd_config'
and on the client, run:
sudo sh -c 'printf "\n\n# Send language environment variables\nSendEnv LANG LC_*" >> /etc/ssh_config'
These commands append lines to your config files. They tell your client and server to respectively send and receive only the environmental variables that control language. You do not have to restart the server after running this command because the new config will be applied to the next session.

[Editor's Note: This hint has not been tested.]

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090712151742269