Linux SSH – Strange Locale Behavior When Using PuTTY from Windows

bashlinuxlocalizationputtyssh

Please,
can someone shed some light on this strange locales related warning annoying me since I installed my server half year ago. It's a variant of "Cannot set LC_CTYPE to default locale", which seems to be a pretty common issue, but mine has a strange twist, not matching any of the cases I found previously reported.

This warning is printed immediately after I log in with PuTTY on Windows to my Linux server.

-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_GB.UTF-8,LANG=en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_GB.UTF-8,LANG=en_US.UTF-8)

Same happens when I use ssh command from Git Bash. When I log using VNC and open Konsole in KDE, Bash opens without any of these warnings.

What is unique to my case is the value it tries to set LC_CTYPE: en_GB.UTF-8,LANG=en_US.UTF-8. It looks like two concatenated strings. How this happened!?

This is original output on server side

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_GB.UTF-8
LC_CTYPE=en_GB.UTF-8,LANG=en_US.UTF-8
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
...
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

Note that:
1) all variables are set except LC_ALL – is that normal?
2) LC_CTYPE has the strange "concatenated" value
3) All values has quotes around except LC_CTYPE
4) warning is similar but complaining also about LC_ALL

I tried to fix it by editing ~/.profile, on the server side, by appending:

export LANG=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8

Now, after re-logging, the locale seems to show reasonable values and no warnings from locale command:

$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
...
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8

Should I worry about some values not having quotes around them?

But the login warning is still there, still pulling en_GB.UTF8,LANG=en_US.UTF-8 from somewhere:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_GB.UTF8,LANG=en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_GB.UTF8,LANG=en_US.UTF-8)

Linux server: "openSUSE Leap 15.0"
Windows client 1: PuTTY 0.70
Windows client 2: Git Bash 2.21.0 (MinTTY terminal)

Any ideas?

PuTTY just after logging in showing LC_CTYPE: cannot change locale warning
ssh in Git Bash just after logging in showing LC_CTYPE: cannot change locale warning

Best Answer

(I can't comment.)

Is /etc/ssh/sshd_config in Linux the following line?

AcceptEnv LANG LC_*