I'm not a newbie, yet I've been battling this apparently easy issue for a while. I know how to work around it using /etc/environment or other tricks but I want the vars in /etc/default/locale to work ... they simply aren't sourced

Using Ubuntu 14.04.4. The current contents of /etc/default/locale are:


I know I can put those in /etc/environment or /etc/profile etc. Triggering dpkg-reconfigure locales, locale-gen, locale-update have zero effect. I know about all of them.

Something that is supposed to source /etc/default/locale is not sourcing it. I can't figure out what. I did reboot too.

This is when I ssh into the machine.

  • I don't think it is supported running sshd without PAM these days. There might be many more different problems then the one you just hit.
    – Jakuje
    Commented Mar 23, 2016 at 21:00

2 Answers 2


... and minutes later I figured it out ... bloody PAM!

Tracked it down by looking at all /etc files sourcing /etc/default/locale and PAM turned up. It sources it in /etc/pam.d/sshd.

Then I remembered that I only recently disabled PAM in /etc/ssh/sshd_config by commenting the line #UsePAM yes when I wanted to jail sftp users via chroot'ing.

Solution: Either re-enable PAM in sshd_config, or source /etc/default/locale in /etc/environment, /etc/profile, or ~/.profile

Mods can delete the question and this answer if they wish. I'll leave them in case others fall through the same crack.


Shouldn't this actually be a bug worth reporting to the Ubuntu devs? Shouldn't locale settings be configured on all logins, regardless whether PAM is used on not?

  • Both /etc/default/locale and /etc/environment are supposed to be parsed by PAM. They are not script files, and hence should not be sourced. Can't see that it's a bug. Commented Mar 23, 2016 at 20:24
  • @GunnarHjalmarsson, That's not what I meant. I meant that (in my view) locale should be set even if PAM is not used in sshd, shouldn't it?. If only PAM parses the dedicated locale env files then one hits the problem described in my question.
    – Normadize
    Commented Mar 23, 2016 at 22:01
  • Well, yes, but PAM is a core feature in Ubuntu, and isn't supposed to be disabled. This is a core design matter, and if you think it's important enough, I'd suppose you bring up the topic e.g. on the ubuntu-devel-discuss mailing list. Commented Mar 23, 2016 at 22:22
  • Why is it not supposed to be disabled? When I read about security hardening (disabling password based ssh login) it suggested to turn UsePAM off as well: cyberciti.biz/faq/how-to-disable-ssh-password-login-on-linux Are they wrong? Commented Oct 26, 2023 at 14:01

Read man ssh, which says (in part), in the ENVIRONMENT section:

 Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
 “VARNAME=value” to the environment if the file exists and users are
 allowed to change their environment.  For more information, see the
 PermitUserEnvironment option in sshd_config(5).  

And, in the FILES section see:

         Contains additional definitions for environment variables; see
         ENVIRONMENT, above.


         Commands in this file are executed by ssh when the user logs in,
         just before the user's shell (or command) is started.  See the
         sshd(8) manual page for more information.


         Commands in this file are executed by ssh when the user logs in,
         just before the user's shell (or command) is started.  See the
         sshd(8) manual page for more information.
  • None of those files exists by default, so it's unlikely they're affecting their environment; more likely, their current environment is being exported into the SSH session.
    – kos
    Commented Mar 23, 2016 at 19:45
  • @kos: It doesn't make sense to copy the originating system's Environment to the target system. The files specified in the man page would let OP solve his problem, without unscrewing PAM
    – waltinator
    Commented Mar 23, 2016 at 19:56
  • I was sure I had seen an option for that, but I must have dreamed. However yeah that, would have been unlikely either on a second thought, still a setup one should have been aware of. OP's answer makes a lot of sense though.
    – kos
    Commented Mar 23, 2016 at 20:08
  • Indeed, and this is useful stuff to keep in mind, but initial question was about something a little different, even though related. The problem was why /etc/default/locale wasn't being sourced, and the reason was PAM (see my own answer).
    – Normadize
    Commented Mar 23, 2016 at 22:09

You must log in to answer this question.

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