I'm having some problems with using ssh and a remote server (which I do not have admin access to) - Specifically, there are a couple of folders on there with Korean and Cyrillic text.

When I display the parent folder contents with ls, the characters are escaped as "?". Perhaps of note is that the Korean characters seem to escape far more ?s than the number of characters that should be there.

I know that the terminal program I'm using can display the characters, as using sftp displays them perfectly. The problem occurs across all terminals I've tried.

Summary of machines

Local machine:

  • Linux 2.6.32-5-686, i686
  • Debian GNU/Linux 6.0.2 (squeeze)
  • Have admin access

Remote server:

  • Linux 2.6.32-bpo.5-amd64, x86_64
  • Debian GNU/Linux 5.0.8 (lenny)
  • Don't have admin access, nor physical

I've probably missed some other vital statistic or bit of information, in which case I apologize. I'm fairly new to the whole non-Windows side of computing, so I barely know what I'm doing here.

  • 2
    post the output from the locale and locale -a commands, both locally and remotely, please
    – enzotib
    Jul 16, 2011 at 11:19
  • Thanks @enzotib - Your comment twigged me onto the idea that the offered locales might not be the same locally and remotely. Jul 19, 2011 at 7:39
  • Possibly related: stackoverflow.com/questions/12649896/… Sep 13, 2023 at 20:30

1 Answer 1


Your locale information isn't set up correctly on the server machine. Specifically, the LC_CTYPE variable, which indicates the encoding of characters on the terminal, isn't set correctly (or, I suspect, at all).

In your local terminal, run locale to see your locale settings. You'll probably see (amongst other lines) something like LC_CTYPE=en_US.UTF-8; what matters here is the .UTF-8 part, indicating the UTF-8 encoding. This is the de facto standard encoding for multilingual text in the unix world (and beyond).

You need to pass this information to the server. The best way, if it works, is to send locale information through the ssh connection. For this, add the following lines at the end of ~/.ssh/config:

Host *
SendEnv LC_* LANG

This requires that a suitable AcceptEnv directive be present in the server configuration (/etc/ssh/sshd_config) (it is by default on Debian).

If that doesn't work, and you always log in to the server from a UTF-8 terminal, add the line export LC_CTYPE=en_US.UTF-8 to your ~/.bashrc on the server (or ~/.zshrc or whatever file your shell uses). The locale name (e.g. en_US.UTF-8) must be one of those offered by locale -a, and must have .UTF-8 (or .utf8 or some trivial variation).

  • 1
    Ah! That'd be the problem: I "use" en_AU.utf8 locally, which seemed to be already forwarded to the server (or, at least, the locale outputs matched). However, locale -a remotely gave only en_GB.utf8 and en_US.utf8. Thanks! Jul 19, 2011 at 7:39
  • 1
    To get the encoding of the current locale, you may also use: locale charmap
    – user9171
    Jul 19, 2011 at 12:09
  • My /etc/ssh/ssh_config required also sending LANG (SendEnv LANG LC_*) Sep 15, 2017 at 15:39
  • And I needed to add export LC_CTYPE=en_US.UTF-8 to my ~/.profile on the server side. Adding it to ~/.bashrc seemed to have no effect.
    – datka
    Mar 27, 2018 at 7:48
  • So, it there a way to set this on the server so that it applies by default to all users, instead of editing every .bashrc or .profile?
    – Sam Sirry
    May 12, 2021 at 15:53

You must log in to answer this question.

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