Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

View international characters in SSH sessions UNIX
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.]
    •    
  • Currently 1.67 / 5
  You rated: 4 / 5 (9 votes cast)
 
[7,613 views]  

View international characters in SSH sessions | 6 comments | Create New Account
Click here to return to the 'View international characters in SSH sessions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
View international characters in SSH sessions
Authored by: merlyn on Jul 14, '09 08:20:10AM

I think those odd-looking "n" are actually "\n" that got eaten by the forum software (once again).



[ Reply to This | # ]
View international characters in SSH sessions
Authored by: fbitterlich on Jul 14, '09 08:21:59AM

Careful! Looks like there are some backslashes missing. Running this as it is could hose your ssh_config file.



[ Reply to This | # ]
View international characters in SSH sessions
Authored by: Macworld_admin on Jul 14, '09 09:02:46AM

The missing backslashes have been added back in.



[ Reply to This | # ]
View international characters in SSH sessions
Authored by: wallybear on Jul 14, '09 04:13:46PM

I understand that giving a single command line can be simpler for novices, but it could be dangerous if wrongly typed (just imagine if they write ">" instead of ">>").

I presume it's better to give the following instructions:

On the server, add the following two lines at the end of /etc/sshd_config:

# Accept language environment variables
AcceptEnv LANG LC_*


On the client, add the following two lines at the end of /etc/ssh_config:

# Send language environment variables
SendEnv LANG LC_*

( You will need superuser privileges to edit those files:
use
sudo nano /etc/sshd_config
or
sudo nano /etc/ssh_config
)



[ Reply to This | # ]
View international characters in SSH sessions
Authored by: Soliman on Jul 16, '09 04:22:21AM
Even better, do the last part locally in your ${HOME}/.ssh/config No need for sudo and no perturbation for other users...

---
Sylvain

[ Reply to This | # ]

View international characters in SSH sessions
Authored by: Aikinai on Oct 10, '09 11:54:27AM
Oh, I just noticed this hint went up awhile ago!
Anyway, thanks a lot for the extra detail wallybear. I was trying to keep the hint easy for anyone to use, but you're right, I should have just said what those commands were doing too.

[ Reply to This | # ]