I have a Debian 6 (64-bit) VPS where I cannot seem to get the locale environment variables LANG and LC_* set. (Everything below as root).

vps:~# locale -a

vps:~# locale

vps:~# cat /etc/default/locale
#  File generated by update-locale

This should override the locale settings provided via my SSH client, but the default locale settings take no effect.

.profile, .bashrc, /etc/environment and /etc/profile do not contain any locale settings. I also haven't found any other locations from where these environment variables are sourced.

me:~# grep "LANG" ~/.profile ~/.bashrc /etc/environment /etc/profile
me:~# grep "LC_" ~/.profile ~/.bashrc /etc/environment /etc/profile

My SSH client settings are not taking effect either, while they do on other VPSes. Locally, I have in my /etc/ssh/ssh_config:

SendEnv LANG LC_*

And on the VPS, /etc/ssh/sshd_config contains:

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

I'm not sure if it's required for the variables to take effect, but my VPS's /etc/pam.d/login contains:

# locale variables are also kept into /etc/default/locale in etch
# reading this file *in addition to /etc/environment* does not hurt
session       required   pam_env.so readenv=1 envfile=/etc/default/locale

And /etc/pam.d/sshd contains:

# Read environment variables from /etc/environment and
# /etc/security/pam_env.conf.
auth       required     pam_env.so # [1]
# In Debian 4.0 (etch), locale-related environment variables were moved to
# /etc/default/locale, so read that as well.
auth       required     pam_env.so envfile=/etc/default/locale

(my /etc/security/pam_env.conf contains only commented options)

So, it seems something is not allowing either my /etc/default/locale or my SSH client's locale settings to take effect, so it defaults to POSIX (or something is forcing POSIX explicitly). Any clues what could be interfering? Or ideas how to find out what it is?

I can do export LC_CTYPE=en_US.UTF-8 etc. in my .bashrc, and that does work. However I'm trying to understand this behavior, which is different from that on other Debian (6 or 7) installations I'm working with.

Edit: some more details:

  • I have rebooted the system, no effect;
  • /etc/ssh/sshd_config has UsePAM yes;
  • I've also tried using en_US.utf8 as alternative name in /etc/default/locale.

closed as off-topic by Thomas Dickey, Anthony Geoghegan, Archemar, GAD3R, Anthon Sep 6 '16 at 9:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Thomas Dickey, Anthony Geoghegan, Archemar, GAD3R, Anthon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Pointing out the obvious, but the relevant locales have been generated, right? You say this does not happen with other VPS's? So probably not the issue. Incidentally, if other VPS's work correctly, why not compare files with them? I've found that a workable debugging strategy in the past. – Faheem Mitha Sep 14 '14 at 17:00
  • Yes, the locales have been generated, see the output of locale -a at the top. Comparing the entire system seems like a lot of work, I was hoping for a more targeted approach. – arjan Sep 14 '14 at 21:32
  • Not the entire system, just selected files. Anything that involves locales, basically. – Faheem Mitha Sep 14 '14 at 21:53
  • 1
    I note that you've checked /etc/pam.d/login but that file is only consulted for local logins (e.g. logging in on the console or other serial ports managed by getty). For SSH login, you'll want to look at /etc/pam.d/sshd instead. Mine does contain the requisite pam_env.so line. Does yours? Finally, you could check the output of env after logging in by SSH just to make sure the environment variable settings for LANG and LC_CTYPE are indeed present. – Celada Sep 15 '14 at 2:33
  • 1
    Let's understand if this is related to ssh: if you connect via ssh with a different user, then export locale variables, then su - to root, does it keep the locale settings? – eppesuig Feb 25 '15 at 17:13

You should verify that [PermitUserEnvironment] in your sshd config file is set to yes as well. I don't know what the default is.

Not the answer you're looking for? Browse other questions tagged or ask your own question.