After installing new systems, I often got the error similar to this:
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
I went looking in the locale definitions, the bashrc, and other environment setting techniques. Turns out SSH is to blame.
From what I understand, this is the fault of ssh, who is passing LC_TYPES to the target system that the target system doesn’t know. So I disable this in SSHD config file (such as
# Accept locale-related environment variables
#AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
#AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
#AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
Simply put, disallow sshd from accepting the guest login’s LC_TYPE.