4

I have a debian server with several locales installed, de_DE, en_GB and en_US. I want to be able to login over ssh and get the locale set accordingly (to en_US in my case, different for someone else) I ran dpkg-reconfigure locales, and selected None as the default locale as mentioned here: http://wiki.debian.org/Locale. Now, when I login over ssh I still get the de_DE locale.

LANG=de_DE.utf8
LANGUAGE=de_DE.utf8
LC_CTYPE="de_DE.utf8"
LC_NUMERIC="de_DE.utf8"
LC_TIME="de_DE.utf8"
LC_COLLATE="de_DE.utf8"
LC_MONETARY="de_DE.utf8"
LC_MESSAGES="de_DE.utf8"
LC_PAPER="de_DE.utf8"
LC_NAME="de_DE.utf8"
LC_ADDRESS="de_DE.utf8"
LC_TELEPHONE="de_DE.utf8"
LC_MEASUREMENT="de_DE.utf8"
LC_IDENTIFICATION="de_DE.utf8"
LC_ALL=de_DE.utf8

I checked with ssh -v, the ssh client is indeed sending the LANG variable

debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8

How is the locale still getting set to DE and how can I disable that behavior?

Edit: It works now. Someone forcibly set the locale in /etc/profile...

BubuIIC
  • 533
  • 5
  • 10

4 Answers4

4

Is specifying the user-preferred locale configurations in ~/.profile appropriate for your needs?

Also, to save you the annoyance, stop forwarding locale from your client (/etc/ssh/ssh_config, comment out SendEnv LANG...) and stop accepting on the server (/etc/ssh/sshd_config)..

Or, if you prefer, you can set a ~/.ssh/environment file with the options you want. You'll have to enable PermitUserEnvironment on the server's /etc/ssh/sshd_config file.

  • I think the forwarding of the locale is not the problem, I actually want that to work. The server not accepting or rather not setting the locale accordingly is the problem. Setting it explicitly in .profile would work. But I was wondering where the system still gets the German locale from. – BubuIIC Jan 11 '13 at 21:44
3

Ok, I figured it out. Someone hard coded the LC_ALL and LANG variables in /etc/profile, so everything else was just ignored. After removing these, the locale now gets set according to the environment transmitted by ssh.

BubuIIC
  • 533
  • 5
  • 10
  • This happened to me too - after a fresh installation of Ubuntu. It turned out my hosting provider manipulated certain files without documenting it. The answer worked for me. – Matt Apr 12 '22 at 19:54
1

Also please check this file:

/etc/default/locale

if you make it empty then it may help too.

next to already mentioned:

/etc/profile
~/.profile
~/.bashrc

each of those files may include some of

LANG
LANGUAGE
LC_*
aNeutrino
  • 111
  • 3
0

In my case when logging in with ssh none of the usual default locale or environment variable settings seemed to work. It was because I had disabled PAM session control in sshd configuration.

Make sure you have set

UsePAM yes 

in your /etc/ssh/sshd_config file, at least this worked for me.

Basil
  • 16