SSH远程连接到Ubutun,添加账号时出现如下错误:
root@LePlanet:~# adduser lienZzzz
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
在Stack Overflow中发现如下帖子,发现是SSH连接时,远程主机的/etc/ssh/sshd_config的文件有如下设置:
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
远端会读取本地的语系配置,但远端支持语系里没有本地当前语系,所以出现上述错误。
本地语系:
zh_CN.UTF-8
远端配置:
root@LePlanet:~# 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_US.UTF-8
LANGUAGE=
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
远端支持语系
root@LePlanet:~# locale -a
locale: Cannot set LC_CTYPE to default
locale: No such file or directory
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
所以,远端需下载 zh_CN.UTF-8
root@LePlanet:~# sudo locale-gen zh_CN.UTF-8
Generating locales...
zh_CN.UTF-8...
doneGeneration complete.
再查看:
root@LePlanet:~# locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
已经不报错:
root@LePlanet:~# locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
此外,可以用sudo locale-gen,更新语系至最新。